Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP preg匹配所有_Php_Regex_Preg Match All - Fatal编程技术网

PHP preg匹配所有

PHP preg匹配所有,php,regex,preg-match-all,Php,Regex,Preg Match All,但我只想要数字 无以下结果: preg_match_all('/\'keep.php\?casuser=(.*) style=\"color:#ffca3e/iU', $result, $matches2); $matches2[1][0] = 400000018623110'); return false;" 有人能帮我吗?解释一下为什么它不起作用? thx有点被这个问题搞糊涂了——如果我有代表的话,我会把它放在评论里 这是否足够 preg_match_all('/\'keep.php\?c

但我只想要数字

无以下结果:

preg_match_all('/\'keep.php\?casuser=(.*) style=\"color:#ffca3e/iU', $result, $matches2);
$matches2[1][0] = 400000018623110'); return false;"
有人能帮我吗?解释一下为什么它不起作用?
thx有点被这个问题搞糊涂了——如果我有代表的话,我会把它放在评论里

这是否足够

preg_match_all('/\'keep.php\?casuser=(.*)\'\); return false;" style=\"color:#ffca3e/iU', $result, $matches2);
或者他们也有相关的风格是重要的吗?如果是,请尝试:

preg_match_all('/\'keep.php\?casuser=(\d*)/i', $result, $matches2);

thx ye style是相关的,非常感谢第二个答案对我有用:)关于为什么你的答案不起作用:第一个匹配casuser=和[space]style=之间的所有字符,第二个匹配casuser=和下一个单引号之间的所有字符,我希望返回400000018623110“onclick=”ajaxLinkSend(',但无论哪种方式都不正确。很高兴能提供帮助。不,我从\'开始,因为我只想要第二个号码:),但我仍然不明白为什么我的第二次尝试不起作用
preg_match_all('/\'keep.php\?casuser=(\d*)/i', $result, $matches2);
preg_match_all('/\'keep.php\?casuser=(\d*).*?style=\"color:#ffca3e/i', $result, $matches2);