[Tutor] module re

Alan Gauld alan.gauld at blueyonder.co.uk
Sun May 2 13:47:32 EDT 2004

>I need to write a program, that delete white spaces, comments, tabs
etc. I
>used module re.compile(text, re.X). The problem is: the result is not
 >string, but an sre object,

The sre object is what you use to perform the replacements.

myRE = re.compile(reString,re.X)
myString = myRE.replace(myString)

myString now has the modified version of the original according
to the re you compiled in the previous step.

Is that anything like what you did?

Alan G

More information about the Tutor mailing list