【发布时间】:2020-04-30 15:58:41
【问题描述】:
我目前正在创建的正则表达式存在问题。正则表达式必须提取在 Hello 和 Regards 之间显示数字 #### 的所有组。目前我的正则表达式只提取一个组,我需要里面的所有组,在这种情况下我有 2 个,但里面可能还有更多。
我正在使用网页https://regex101.com/
风格:PCRE (PHP)
正则表达式:Hello\s.*(number\s*[\d]*)\s.*Regards
文字:
This is my test text number 25120
Hello my name is testing
I'm 20 years old
Please help me with the regex number 1542
I have been trying to create the regex many times this is my number 5152
Regards
I'm still trying my attempt number 5150
结果:
我的结果只是组号 5152 但里面是另一个组号 1542。
【问题讨论】:
-
欢迎来到 SO!请参阅why not upload images of code when asking a question。捕获组始终只保存最后一场比赛。
标签: regex pcre regex-group