【发布时间】:2019-08-07 09:51:24
【问题描述】:
我正在尝试使用段落分隔字符串(即实际上它们是电子邮件中的线程),并且我需要根据字符串的句子而不是单词来拆分字符串。
我试过的是:
def split_text_from_sentence(text, sentence):
chopped_text = re.split(sentence, text)
return chopped_text
我得到了什么:
full_text = ¨Good morning Carlos. We leave you attached the excel for info. Regards. Luis Miguel. Company Name blablabla From: Oscar Herrero, Carlos Sent: tuesday 25 of octoberFor: Administration Matter: [INTERNAL] Good afternoon, I need to ask you for a requirement to add in Sharepoint. Un saludo, Carlos OSCAR HERRERO engineering Support T8 1st floor | carlos.oscar-herrero@blabla.com¨
signature_text = ¨From: Oscar Herrero, Carlos Sent: tuesday 25 of octoberFor: Administration Matter: [INTERNAL]¨
我正在寻找类似的东西:
first_message = ¨Good morning Carlos. We leave you attached the excel for info. Regards. Luis Miguel. Company Name blablabla ¨
rest_of_message = ¨Good afternoon, I need to ask you for a requirement to add in Sharepoint. Un saludo, Carlos OSCAR HERRERO engineering Support T8 1st floor | carlos.oscar-herrero@blabla.com¨
【问题讨论】:
标签: regex python-3.x string split