我试图匹配一个数字后面出现的单词 - 在下面的句子中,它是单词"米".
塔高100 米.
这是我尝试的模式不起作用:
\d+\s*(\b.+\b)但是这个做了:
\d+\s*(\w+)第一个不正确的模式与此匹配:
塔高 100 米.
我不想要"高"这个词匹配.我期望以下行为:
\d+ match one or more occurrence of a digit
\s* match any or no spaces
( start new capturing group
\b find the word/non-word boundary
.+ match 1 or more of everything except new line
\b find the next word/non-word boundary
) stop capturing group
问题是我不知道关于正则表达式的问题,而且我非常喜欢菜鸟.我正在练习制造自己的问题并试图解决它们 - 这是其中之一.为什么比赛在第二次休息时没有停止(\b)?
这是Python风格
这里是上述正则表达式的regex101测试链接.