【发布时间】:2018-08-02 01:00:05
【问题描述】:
我有一个包含以下数据的文本文件:
Last name, First name in some of the cases
例如:
The patient was referred by Dr. Douglas, John, updated by: Acosta, Christina
The patient was referred by Potter, Rob,M.D.
Sam was referred by Dr. Alisa Russo
我想输出为:
John Douglas
Rob Potter
Alisa Russo
我使用的代码是:
print(str(string.partition(',')[2].split()[0] +" "+string.partition(',')[0].split()[0]))
【问题讨论】:
-
鉴于字符串的极端可变性,我认为您无法期望正则表达式能够为您提供所需的内容。
-
为什么不打印 Acosta, Cgristina
-
我们只需要推荐的医生
标签: regex python-3.x spacy data-extraction