页面部份代码如下:emailtofriend3.gif" 
                        align=absMiddle border=0></A> <BR><BR><SPAN 
                        style="FONT-SIZE: 12px">i would like meet some people to 
                        play at day time on the week day like <BR>(mon-fri) 
                        anyday . i am normal playing , not very strong playing! 
                        ho man tin ,or other place is fine!thank you!</SPAN> <!-- Signature Advertising - Modified by Ivan - start-->
                    <TR>
                      <TD bgColor=#ffff00 height=25>&nbsp;廣告: <A 
                        href="http://live.tipswin.com/" target=_blank><FONT 
                        color=#0000ff>有「射門次數」的現場比分網,波神TV日日有波睇,入來一齊贏波啦!</FONT></A></TD></TR><!-- Signature Advertising - Modified by Ivan - end--></TD></TR></TBODY></TABLE></TD></TR>
奔厅奔厅</SPAN>大幅度</SPAN>
我要取到 emailtofriend3.gif  到最近一个</SPAN> 之间的内容,请问用正则表达式该怎么搞?

解决方案 »

  1.   

    $str='...'
    preg_match('/emailtofriend3\.gif(.*)\<\/span\>/is',$str,$post2);
      

  2.   

    楼上的你的程序也是读取最后一个</span>,不是第一个</span>.
      

  3.   

    使用非贪婪
    preg_match('/emailtofriend3\.gif(.*?)\<\/span\>/is',$str,$out);
      

  4.   

    preg_match('/emailtofriend3\.gif(.*?)\<\/span\>/is',$str,$out);.*? 及 is 是什么意思呀?
      

  5.   

    .*?表示非贪婪匹配,意思就是前面的串emailtofriend3.gif和后面的串</span>中间的部分应该尽可能的少。
    is是模式修正符,i表示忽略大小写,s可以让"."匹配到换行符