yyydddd<IMG style="WIDTH: 201px; HEIGHT: 213px" height=533 alt="" hspace=0 src="C:\Documents and Settings\Administrator\桌面\dasha.jpg" width=277 align=baseline border=0 name=im id=im>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--function button1_onclick() {
alert(document.all.im.src);}//-->
</SCRIPT>

解决方案 »

  1.   

    s = 'yyydddd<IMG style="WIDTH: 201px; HEIGHT: 213px" height=533 alt="" hspace=0 src="C:\Documents and Settings\Administrator\桌面\dasha.jpg" width=277 align=baseline border=0>';
    re = /src="(.*?)"/i;
    if (re.test(s))
     alert(RegExp.$1);s2 = '123456789';
    s = s.replace(re,'src="' + s2 + '"');
      

  2.   

    <script>str='yyydddd<IMG style=\"WIDTH: 201px; HEIGHT: 213px\" height=533 alt=\"\" hspace=0 src=\"C:\\Documents and Settings\\Administrator\\桌面\\dasha.jpg\" width=277 align=baseline border=0>';str = str.replace(/^.*src=\"(.*?)\".*$/gi,"$1");
    alert(str);
    </script>
      

  3.   

    <body>
    <span id="code">
    yyydddd<IMG style="WIDTH: 201px; HEIGHT: 213px" height=533 alt="" hspace=0 src="C:\Documents and Settings\Administrator\桌面\dasha.jpg" width=277 align=baseline border=0>现有如上面的字符串,我想从中找出所有src="*"引号中间的字符串内容,src=""在字符串中出现的位置不确定,怎么操作!
    </span>
    </body>
    <script>
    s = code.innerHTML;
    alert(s.match(/\bsrc="(.*?)"/)[1]);
    </script>
      

  4.   

    替换多个的话,思归的应该加一个g的,<script>
    s='yyydddd<IMG style=\"WIDTH: 201px; HEIGHT: 213px\" height=533 alt=\"\" hspace=0 src=\"C:\\Documents and Settings\\Administrator\\桌面\\dasha.jpg\" width=277 align=baseline border=0>yyydddd<IMG style=\"WIDTH: 201px; HEIGHT: 213px\" height=533 alt=\"\" hspace=0 src=\"C:\\Documents and Settings\\Administrator\\桌面\\dasha.jpg\" width=277 align=baseline border=0>';
    re = /src=\"(.*?)\"/gi;  
    if (re.test(s))
     alert(RegExp.$1);s2 = '123456789';
    s = s.replace(re,'src="' + s2 + '"');
    alert(s);
    </script>
      

  5.   

    这个字符传中可能不只一个和src有关的子字符串!
      

  6.   

    我的程序是:
    re = /src=\"(.*?)\"/g; 
    alert(document.input.epdescr.value);
    if (re.test(document.input.epdescr.value)){
    myArray = re.exec(document.input.epdescr.value);
    }
    alert(myArray[1]);
    alert(myArray[2]);
    其中document.input.epdescr.value是
    <IMG alt="" hspace=0 src="file:///C:/Documents%20and%20Settings/Administrator/桌面/welcome.gif" align=baseline border=0><IMG alt="" hspace=0 src="file:///C:/Documents%20and%20Settings/Administrator/桌面/dasha.jpg" align=baseline border=0>
    可是执行结果为:
    alert(myArray[1]);为file:///C:/Documents%20and%20Settings/Administrator/桌面/welcome.gif(没错)
    file:///C:/Documents%20and%20Settings/Administrator/桌面/welcome.gif;undefined(没有值)为什么会这样
    而且
    myArray[0]也是:file:///C:/Documents%20and%20Settings/Administrator/桌面/welcome.giffile:///C:/Documents%20and%20Settings/Administrator/桌面/welcome.gif怎么会€变最后匹配字符€串?请高手指点,搞定马上送分!
      

  7.   

    我的程序是:
    re = /src=\"(.*?)\"/g; 
    alert(document.input.epdescr.value);
    if (re.test(document.input.epdescr.value)){
    myArray = re.exec(document.input.epdescr.value);
    }
    alert(myArray[1]);
    alert(myArray[2]);
    其中document.input.epdescr.value是
    <IMG alt="" hspace=0 src="file:///C:/Documents%20and%20Settings/Administrator/桌面/welcome.gif" align=baseline border=0><IMG alt="" hspace=0 src="file:///C:/Documents%20and%20Settings/Administrator/桌面/dasha.jpg" align=baseline border=0>
    可是执行结果为:
    alert(myArray[1]);为file:///C:/Documents%20and%20Settings/Administrator/桌面/welcome.gif(没错)
    alert(myArray[2]);undefined(没有值)为什么会这样
    而且
    myArray[0]也是:file:///C:/Documents%20and%20Settings/Administrator/桌面/welcome.giffile:///C:/Documents%20and%20Settings/Administrator/桌面/welcome.gif怎么会€变最后匹配字符€串?请高手指点,搞定马上送分!