擅长:python、mysql、java
<p>您可以使用regex组来实现这一点。下面是一些示例代码:</p>
<pre><code>import re
teststring = "This is a test of number, number: 525, number: 585, number2: 559"
groups = re.findall(r"number2?: (\d{3})", teststring)
</code></pre>
<p><code>groups</code>然后包含数字。此语法使用正则表达式组。</p>