擅长:python、mysql、java
<p>下面的正则表达式按预期工作。你知道吗</p>
<p><strong>代码的相关部分:</strong></p>
<pre><code>nameRegex = re.compile(r"^[a-zA-Z]+[',. -][a-zA-Z ]?[a-zA-Z]*$", re.MULTILINE)
print(nameRegex.findall(directory)
</code></pre>
<p><strong>输出:</strong></p>
<pre><code>>>> python3 test.py
['Mark Adamson', 'Allison Andrews', 'Dustin Andrews']
</code></pre>