1

trying to extract useful string content in a chain of email messages.

text = """I have a string which is a chain of email messages like this:
From: x,y 
Sent: Monday, January 07, 2018 12:48 PM
To: a,b
Cc: p,q
Subject: subject
Importance: High 
Hi a,
some useful message body 1

Thanks

From: x,y 
Sent: Monday, January 06, 2018 12:48 PM
To: a,b
Cc: p,q
Subject: subject
Importance: High 
Hi b,

some useful message body 2

Best"
useful_output = re.sub((From.*Importance)+, '',text)

expected result : it should replace From to Importance patterns anywhere in text with null leaving useful content in between. the result expected would be something like : "Hi a,some useful message body 1 Thanks Hi b, some useful message body 2 Best"

but the result is same as input

cs95
  • 274,032
  • 76
  • 480
  • 537
pat
  • 115
  • 1
  • 9

0 Answers0