擅长:python、mysql、java
<p>不带regexp</p>
<pre><code>text = ['C1412DRE, New York 2695','Direction 12','Main Street 6254 C13D']
str = ' '.join(text)
[int(s) for s in str.split() if s.isdigit()]
[2695, 12, 6254]
</code></pre>
<p>使用regexp:</p>
<pre><code>import re
re.findall(r'\b\d+\b', str)
['2695', '12', '6254']
</code></pre>
<p>把它们转换成数字</p>
<pre><code>[int(s) for s in re.findall(r'\b\d+\b', str)]
[2695, 12, 6254]
</code></pre>
<p><a href="https://docs.python.org/3/library/re.html" rel="nofollow noreferrer">https://docs.python.org/3/library/re.html</a></p>
<p>您可以使用codegen尝试regexp:<a href="https://regex101.com/r/4kUHhq/1" rel="nofollow noreferrer">https://regex101.com/r/4kUHhq/1</a></p>