擅长:python、mysql、java
<p>您可以尝试使用<a href="http://docs.python.org/2/library/re.html#re.findall" rel="nofollow noreferrer">findall</a>。例如</p>
<pre><code>import re
regex = re.compile(r'(?P<g1>3s)|(?P<g2>ye)')
regex.findall(test_string)
</code></pre>
<p>这将返回匹配项的元组列表,如下所示:</p>
<pre><code># Output
# [('3s', ''), ('', 'ye'), ('3s', ''), ('', 'ye')]
</code></pre>
<p>我编译的正则表达式没有您想要的所有命名组,但是您可以很容易地添加它们。你知道吗</p>