$str="......";
preg_match('/<SPAN style="FONT-SIZE: 12px">(.*?)</SPAN>/ix', $str, $post);echo $post[1];//输出(.*)
preg_match('/<SPAN style="FONT-SIZE: 12px">(.*?)</SPAN>/ix', $str, $post);echo $post[1];//输出(.*)
但我是要循环多个页面的,所以<SPAN style="FONT-SIZE: 12px">(.*?)</SPAN>没唯一性。我是这样做的:
eregi('emailtofriend3.gif(.*)<TR><TD bgColor=#ffff00 height=25>', $page, $post2);这是唯一性:<TR><TD bgColor=#ffff00 height=25>但不知道是<TR>及<TD bgColor=#ffff00 height=25>之间有什么字符存在,所以取不到数据。
or:
eregi('emailtofriend3.gif([^<]*)<TR><TD bgColor=#ffff00 height=25>', $page, $post2);(但是这里面不能有<BR>之类的)
<TD bgColor=#ffff00 height=25>
在网页上看到是这样的。所以用上面的方法老是不行的。
http://www.aka.org.cn/Lectures/001/Lecture-6/PerlReg_8rule.html
这个讲正则比较详细
preg_match_all('/[^\<SPAN style=\"FONT\-SIZE\: 12px\"\>]([[:alpha:]_-\s[:punct:]]*)<\/SPAN>/',$str, $match);
print_r($match);
eregi('emailtofriend3.gif(.*)<TR><TD bgColor=#ffff00 height=25>', $page, $post2);这是唯一性:<TR>
<TD bgColor=#ffff00 height=25>但不知道是<TR>及<TD bgColor=#ffff00 height=25>之间有什么字符存在,所以取不到数据。
试试看这个
preg_match('/<SPAN style="FONT-SIZE: 12px">(.*?)</SPAN>/ixs', $page, $post2);
preg_match('/'emailtofriend3.gif(.*?)<TR><TD bgColor=#ffff00 height=25>/is', $page, $post2);
preg_match('/emailtofriend3.gif(.*?)<TR><TD bgColor=#ffff00 height=25>/is', $page, $post2);