且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

正则表达式捕获重复的组

更新时间:2022-10-16 14:43:05

当您在正则表达式中重复捕获组时,捕获组仅存储上一次迭代匹配的文本.如果需要捕获多个迭代,则需要使用多个正则表达式. (.NET是唯一的例外.它的CaptureCollection提供捕获组所有迭代的匹配项.

When you repeat a capturing group in a regular expression, the capturing group only stores the text matched by its last iteration. If you need to capture multiple iterations, you'll need to use more than one regex. (.NET is the only exception to this. Its CaptureCollection provides the matches of all iterations of a capturing group.