Question : Simple Regex Replace

I'm trying to take a string and delete a table object.
Code Snippet:
1:
2:
regex = "(.*
)" cleanstring = re.compile(regex, re.MULTILINE|re.DOTALL).sub('', mystring)
Open in New Window Select All

Answer : Simple Regex Replace

Works for me, perhaps you should provide a sample of mystring, and what you expect cleanstring to be after.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
mystring = """\

I want this gone!

I wish this would stick around, but I'm greedy!

I want this gone, too!
""" greedy = re.compile("(.*
)", re.MULTILINE|re.DOTALL) nongreedy = re.compile("(.*?
)", re.MULTILINE|re.DOTALL) # >>> greedy.sub('', mystring) # '\n\n' # >>> print nongreedy.sub('', mystring) # "\n\n

I wish this would stick around, but I'm greedy!

\n\n"
Open in New Window Select All
Random Solutions  
 
programming4us programming4us