Newbie regular expression and whitespace question
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Thu Sep 22 16:50:24 EDT 2005
googleboy a écrit :
> Hi.
>
> I am trying to collapse an html table into a single line. Basically,
> anytime I see ">" & "<" with nothing but whitespace between them, I'd
> like to remove all the whitespace, including newlines. I've read the
> how-to and I have tried a bunch of things, but nothing seems to work
> for me:
>
> --
>
> table = open(r'D:\path\to\tabletest.txt', 'rb')
> strTable = table.read()
>
> #Below find the different sort of things I have tried, one at a time:
>
> strTable = strTable.replace(">\s<", "><") #I got this from the module
> docs
From which module's doc ?
">\s<" is the litteral string ">\s<", not a regular expression. Please
re-read the re module doc, and the re howto (you'll find a link to it in
the re module's doc...)
More information about the Python-list
mailing list