[英]How to capture match group
Given string 给定字符串
"1s func(), 2s func()"
Wanted result 想要的结果
['func()', 'func()']
Tried 试过了
/[Az]*\\(.*\\)/g
Unfortunately only results in 1 match ['func(), 2s func()']
不幸的是,只有1个匹配项
['func(), 2s func()']
Because '), 2s func('
passes .*
因为
'), 2s func('
通过.*
[A-Za-z]*\(.*?\)
^^
Make it non greedy. 使其不贪婪。
Also change the character selector to [A-Za-z]
, rather than [Az]
, to avoid all the intermediate ASCII characters. 还要将字符选择器更改为
[A-Za-z]
而不是[Az]
,以避免所有中间ASCII字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.