<p>我试图匹配出现在数字后面的单词——在下面的句子中,它是“米”这个词。你知道吗</p>
<blockquote>
<p>The tower is 100 <strong>meters</strong> tall.</p>
</blockquote>
<p>以下是我尝试的模式,但没有成功:</p>
<h2><strong><code>\d+\s*(\b.+\b)</code></strong></h2>
<p>但这次是这样的:</p>
<h2><strong><code>\d+\s*(\w+)</code></strong></h2>
<p>第一个不正确的模式与此匹配:</p>
<blockquote>
<p>The tower is 100 <strong>meters tall</strong>.</p>
</blockquote>
<p>我不想和“高”这个词匹配。我预期会有以下行为:</p>
<p><strong><code>\d+</code></strong><code>match one or more occurrence of a digit</code><br/>
<strong><code>\s*</code></strong><code>match any or no spaces</code><br/>
<strong><code>(</code></strong><code>start new capturing group</code><br/>
<strong><code>\b</code></strong><code>find the word/non-word boundary</code><br/>
<strong><code>.+</code></strong><code>match 1 or more of everything except new line</code><br/>
<strong><code>\b</code></strong><code>find the next word/non-word boundary</code><br/>
<strong><code>)</code></strong><code>stop capturing group</code><br/></p>
<p>问题是我对regex一窍不通,而且我是个十足的noob。我通过自己解决问题来练习——这就是其中之一。为什么比赛没有在第二次休息时停止?你知道吗</p>
<hr/>
<p><sub>这是Python味的<br/>
<a href="https://regex101.com/r/iJ1xE3/1" rel="nofollow">Here's the regex101 test link of the above regex.</a></sub></p>