©
本文檔使用 php中文網手册 發布
在字符类外部,模式中的句点匹配目标字符串中的任意字符,包括非打印字符, 但是(默认)不包括换行符。如果 PCRE_DOTALL 被设置,句点就会匹配换行符。 句点的处理和^、$的处理没有关联,它们唯一的关系是它们都涉及到了换行符。 句点在字符类中没有任何意义。
\C可以被用于匹配单字节, 也就是说在UTF-8模式下,句点可以匹配多字节字符。
[#1] Anonymous [2011-02-02 03:46:27]
Consider,
preg_match_all("/<img.*>/", $htmlfile, $match);
Since PCRE_DOTALL is not used, this pattern is expected to NOT make matches across multiple lines. However, in somecases it can, depending on the PCRE default settings and your data ($htmlfile). The problem is that some are set to recognize NEWLINES differently.
To fix this use,
preg_match_all("/(*ANY)<img.*>/", $htmlfile, $match);
Now, any character that could possibly be seen as a newline will be interpreted as a newline by the PCRE.
NOTE: This pattern has been available since PCRE version 7.3