简体   繁体   English

如何记住正则表达式中的所有出现?

[英]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. 原来,只记得最后一个条目,我也想抓住所有其他条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM