PHP preg_match_all表现得很奇怪

时间:2017-03-09 10:15:13

标签: php regex preg-match preg-match-all

我正在使用正则表达式搜索。但搜索不能使用php preg_match_all方法。但是当我在regex101使用相同的模式时,它在那里完美地工作。所以任何线索我都缺少。代码和主题如下

preg_match_all($patern, $str, $match,PREG_OFFSET_CAPTURE);

//++ the pattern
~\](.*?)\[\d~

//The str or subject

[07-Jul-2016 04:33:15] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0 [07-Jul-2016 04:34:17] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0 [07-Jul-2016 05:14:01] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0 [08-Jul-2016 23:27:23] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0 [10-Jul-2016 03:14:02] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0 [17-Jul-2016 03:42:01] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0 [24-Jul-2016 03:33:01] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0 [31-Jul-2016 03:28:01] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0 [07-Aug-2016 04:24:02] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0 [11-A

匹配的输出如下

array(2) { [0]=> array(0) { } [1]=> array(0) { } }    

基本上我想捕获所有警告或错误消息, 但主要担心的是该模式正在regex101.com上运行,但不在我的代码中

0 个答案:

没有答案