一句php解析html页面的脚本问题



 preg_match_all('/<td width="20%" align="left">.*<\/td>/u',$html,$match,PREG_OFFSET_CAPTURE);

主要是其中的正则表达式没看明白,开头的 / 和结尾的 /u 是代表其中的内容是unicode么?不需要用 \ 转译这两个 /

然后 PREG_OFFSET_CAPTURE 这个flag到底又什么用,看了文档还是没怎么明白,希望各位大大指教

正则表达式 php

纳尼亚哈那一卡 10 years, 3 months ago

/ / 是表示中间内容是表达式。 u 是修饰符,定义这个模式字符串被认为是utf-8的。

http://www.php.net/manual/zh/reference.pcre.pattern.modifiers.php

口琴323 answered 10 years, 3 months ago

Your Answer