Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regex Pattern
#4
import re

with open('email.txt', 'r') as f:
    text = f.read()
    
p = re.compile(r'<!--.*-->',re.DOTALL)
text = p.sub('', text)

p = re.compile(r'^\s*$', re.MULTILINE)
text = p.sub('', text)

print(text)
Reply


Messages In This Thread
Regex Pattern - by NewBeie - May-07-2019, 07:44 AM
RE: Regex Pattern - by Gribouillis - May-07-2019, 09:38 AM
RE: Regex Pattern - by snippsat - May-07-2019, 02:06 PM
RE: Regex Pattern - by michalmonday - May-08-2019, 11:50 AM
RE: Regex Pattern - by NewBeie - May-13-2019, 05:48 AM
RE: Regex Pattern - by michalmonday - May-13-2019, 01:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Regex pattern match WJSwan 2 1,315 Feb-07-2023, 04:52 AM
Last Post: WJSwan
  regex pattern to extract relevant sentences Bubly 2 1,901 Jul-06-2021, 04:17 PM
Last Post: Bubly
  Reading a Regex pattern stahorse 12 5,269 Apr-25-2019, 10:21 AM
Last Post: NewBeie
  Regex, creating a pattern stahorse 5 3,235 Apr-24-2019, 08:29 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020