<script language=javascript>
var str='<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_i1025 style="WIDTH: 464.25pt; HEIGHT: 55.5pt" type = "#_x0000_t75" coordsize = "21600,21600"><v:imagedata o:title="aa" src = "file:///C:\DOCUME~1\陈金发\LOCALS~1\Temp\msohtml1\01\clip_image001.png"></v:imagedata></v:shape>'
re=/(src\s*=\s*\"[^"]+\")/i
re.test(str)
str="<img "+RegExp.$1+"/>"
alert(str)
</script>

解决方案 »

  1.   

    感谢,几乎是可以解决问题了,只是字符串str前后不为空,取得的结果应该是
    "....<img src='省略'/>...."帮忙再改进一下,感激不尽
      

  2.   

    <script >
    str='<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_i1025 style="WIDTH: 464.25pt; HEIGHT: 55.5pt" type = "#_x0000_t75" coordsize = "21600,21600"><v:imagedata o:title="aa" src = "file:///C:\DOCUME~1\陈金发\LOCALS~1\Temp\msohtml1\01\clip_image001.png"></v:imagedata></v:shape>'
    var re=/(src \= \".[^\"]+\")/gi;
    re.test(str);
    str='<img '+RegExp.$1+'>';
    alert(str);
    </script>
      

  3.   

    前后不为空,从什么地方开始要保留?下面是只把<v:imagedata 替换掉的正则
    <script language=javascript>
    var str='<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_i1025 style="WIDTH: 464.25pt; HEIGHT: 55.5pt" type = "#_x0000_t75" coordsize = "21600,21600"><v:imagedata o:title="aa" src = "file:///C:\DOCUME~1\陈金发\LOCALS~1\Temp\msohtml1\01\clip_image001.png"></v:imagedata></v:shape>'
    re=/<v:imagedata(.+?)(src\s*=\s*\"[^"]+\")(.+?)<\/v:imagedata>/i
    re.test(str)
    str=str.replace(re,"<img "+RegExp.$2+"/>")
    alert(str)
    </script>
      

  4.   

    把整个<?xml >...</v:shape>都需要替换
      

  5.   

    <script language=javascript>
    var str='asdasd<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_i1025 style="WIDTH: 464.25pt; HEIGHT: 55.5pt" type = "#_x0000_t75" coordsize = "21600,21600"><v:imagedata o:title="aa" src = "file:///C:\DOCUME~1\陈金发\LOCALS~1\Temp\msohtml1\01\clip_image001.png"></v:imagedata></v:shape>fghfgh'
    re=/<\?xml:(.+?)(src\s*=\s*\"[^"]+\")(.+?)<\/v:shape>/i
    str=str.replace(re,"<img $2/>")
    alert(str)
    </script>
      

  6.   

    有个小小的要求,如果源字符中包含有两个或两上以上的"<?xml:>...</v:shape>",目前只会替换第一个,可不可以做点简单修改???
      

  7.   

    to hbhbhbhbhb1021(天外水火(我要多努力))
        我爱死你了,帮我解决了烦人的问题!    一会儿结帐,如果分数觉得不够,我再看一个问题再给分
      

  8.   

    加个g就可以了
    re=/<\?xml:(.+?)(src\s*=\s*\"[^"]+\")(.+?)<\/v:shape>/ig