ss="<a href='/games/game2288.html' ><img  src='/pic/001.gif'  width="126" height="80" border="0" /></a>"
re = /\/pic\/001.gif/g;             // 创建正则表达式模式。
 r = ss.replace(re, "A");    // 用 "A" 替换 "/pic/001.gif"。

解决方案 »

  1.   

    '/pic/001.gif'  
    这块是个变化的,英文或者数字
      

  2.   

    var yourStr = "aaa" ;
    var str = "<a href='/games/game2288.html' ><img  src='/pic/001.gif'  width=\"126\" height=\"80\" border=\"0\" /></a>"
    var re = new RegExp( "<img[^>]*src[\\s]*=[\\s]*[\'\"]?([^\'\"\\s]*)[\'\"]?[\\s]+" , "g" ) ;
    if( re.test( str ) )
    {
    str = str.replace( RegExp.$1 , yourStr ) ;
    }
    alert( str )
      

  3.   

    为什么不为Img设置ID,然后更改SRC属性了