字符串如下:
1933 the sneaking10 around, she said, was distressing11.
我要匹配以字符串开始数字结尾的子串中的数字。 10和11, 单独的 1933 不用匹配。
现在 [a-z]+\d+ 可以匹配到 sneaking10和 distressing11
如何在这个的基础上在匹配数字呢?
1
darer 2022 年 12 月 31 日
要用断言咧
|
2
Boyce 2022 年 12 月 31 日
[a-z]+(\d+)
|
3
darer 2022 年 12 月 31 日 (?<=[a-zA-Z])\d+
|
7
wudicgi 2022 年 12 月 31 日 @morri #4 我一般查的时候就看这个文档,页面中有 零宽断言 (?<=exp) 匹配 exp 后面的位置
https://deerchao.cn/tutorials/regex/regex.htm |
8
Uyloal 2022 年 12 月 31 日
试试这个行不行 https://imgur.com/a/vdhd8y5
|
9
Nile20 2023 年 1 月 1 日
正则表达式还是孰能生巧,推荐个网站,可以在线编辑表达式并实时查看匹配效果
https://regex101.com/ |