非常に長い文字列から人の名前を抽出する必要があります。
名前の形式は、LAST、FIRST です。
これらの人々の中には、ハイフンでつながれた名前を持っている人もいます。そうでない人もいます。
より小さな文字列での私の試み:
入力:
import re
text = 'Smith-Jones, Robert&Epson, Robert'
pattern = r'[A-Za-z]+(-[A-Za-z]+)?,\sRobert'
print re.findall(pattern, text)
期待される出力:
['Smith-Jones, Robert', 'Epson, Robert']
実際の出力:
['-Jones', '']
私は何を間違っていますか?