如题,一长串字符串中可能会包括多个<a href="">和<img src="">希望把href=""和src=""中的链接地址全部替换成某地址,但要保留后面的文件名。如href="file://a/11.doc" -----> href = "http://www.a.com/a/11.doc"
  src="file://a/22.gif" -----> href = "http://www.a.com/a/22.gif"字符串中可能有多个这样的地址。谢谢!

解决方案 »

  1.   


    string.Replace("href="file://", "href = "http://www.a.com/");
    string.Replace("src="file://", "src ="http://www.a.com/");
      

  2.   

    在客户端用js更方便,可以先遍历form得到<a>和<img>对象,再将其href和src属性修改即可。
      

  3.   


    string output = Regex.Replace(input,"(?is)(?<=<(a|img)\b.*?(href|src)="")file://","http://www.a.com/");