[英]How to Add Groups to Capture Words from RegEx split pattern?
I have the following RegEx pattern, which seems to work properly in matching the words in a string, with words separated by a colon (:): 我有以下RegEx模式,该模式似乎可以正确匹配字符串中的单词,并用冒号(:)分隔单词:
/"[^"]*"|[^:]+/g
using RegEx101.com 使用RegEx101.com
It properly identifies the words. 它可以正确识别单词。 But how do I add capture groups that will work with n words? 但是,如何添加可以使用n个单词的捕获组?
For example, search of 例如,搜索
10:05:12:00
should return 4 groups of 10 05 12 00
应该返回4组,每组10 05 12 00
Ultimately this pattern will be used in a Keyboard Maestro Search Using RegEx Action. 最终,此模式将在使用RegEx Action的Keyboard Maestro搜索中使用。
TIA. TIA。
The answer really came from @TessellatingHeckler in his/her comment above: 答案确实来自@TessellatingHeckler在他/她的上述评论中:
Have you tried any capture groups? 您是否尝试过任何捕获组? Does
/("[^"]*"|[^:]+)/g
work? It seems to on regex101.com/("[^"]*"|[^:]+)/g
起作用?在regex101.com上似乎可以使用
Best implementation in KM is TBD. KM中最好的实现方法是待定。
For completeness and future ref, here's a screenshot: 为了完整性和将来的参考,下面是屏幕截图:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.