我正在为 Sublime Text 编辑器(使用 Oniguruma 正则表达式定义)编写语法荧光笔。基本上,我有这样的事情:
正则表达式:
\((\w+\s*)*\)
测试:
(how are you)
捕获组:
1. you
我的问题是,只有捕获组中的最后一次匹配(因此突出显示)而不是捕获组的全部内容。
在我的具体情况下:
正则表达式:
\(\w+(\s+(\?\w+\s+)+-\s+(\w+))*\)
测试:
(at ?l - location ?x - object)
捕获组:
1. ?x - object
2. ?x
3. object
但是,我想匹配整个组的内容,如下所示:
1. ?x - object AND ?l - location
2. ?x AND ?l
3. object AND location