我正在为Atom编写语法语法主题,但是当我需要使用lookforward/lookbehind
代替non-capturing group
时,我没有区别。
例如,我想在此字符串中获取option
:first (secondfixedword option)
。
(?:\(secondfixedword\s+)([a-zA-Z1-9]+)(?:\))
我将匹配(secondfixedword option)
,但捕获的群组仅为option
。(?<=\(secondfixedword)(?:\s*)([a-zA-Z1-9]+)(?=\))
我只会抓取option
。 (后面有空格,因为我不能使用lookbehind
长度不固定)有时不支持lookbehind
,那我该怎么办?
我看到了matching
,capturing
和non capturing
组之间的区别,但对我来说,我们可以模拟与lookbehind
和lookforward
相同的行为non capturing group
。
我想在value
或if (value)
或if ( value )
中匹配if ( value )
。有很多空格或没有。
谢谢。