擅长:python、mysql、java
<p>在列表中使用<strong><code>join</code></strong>之后,可以使用<strong><code>re.findall</code></strong>:</p>
<pre><code>>>> re.findall(r'(\[.*?\]|\(.*?\))', ''.join(a))
['[Test]', '(Link)', '[Test2]', '(link2)', '[test3]', '(link3)']
</code></pre>
<p>正则表达式解释:</p>
<pre><code>( # Matching group 1
\[.*?\] # Matches non-greedily in between brackets
| # OR
\(.*?\) # Matches non-greedily between parenthesis
) # End of matching group
</code></pre>