Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
只是说我有以下文本要由正则表达式处理:
red red red blue
为了匹配文本,我使用以下正则表达式:
(red\s*)+(blue)
现在,我的问题是如何捕获第一组(不是第一组)?
只需在要捕获的内容周围添加括号,在本例中为整个+ed 组:
+
((red\s*)+)(blue)