[英]how to remember all the occurrences in REGEX?
There is a line 有一条线
int gg = 665 j h = 78;
Check it on the condition and memorize the characters gg, j, h. 根据情况检查并记住字符gg,j,h。 Wrote regex:
编写正则表达式:
/^\s*int\s+(?:\s*([a-z]+)\s*(?:=\s*[0-9]+\s*){0,1})+;$/
Get: 得到:
Array
(
[0] => Array
(
[0] => int gg =665 j h = 78;
),
[1] => Array
(
[0] => h
)
)
It turned out that only remember the last entry, I want to catch all the others too. 原来,只记得最后一个条目,我也想抓住所有其他条目。
Have a look at preg_match_all
看看
preg_match_all
http://php.net/manual/en/function.preg-match-all.php http://php.net/manual/zh/function.preg-match-all.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.