how to remove <BR> using replace function?
Duncan Booth
duncan.booth at invalid.invalid
Fri Feb 10 03:56:55 EST 2006
Sion Arrowsmith wrote:
> Duncan Booth <duncan.booth at suttoncourtenay.org.uk> wrote:
>>Although I generally advise against overuse of regular expressions,
>>this is one situation where regular expressions might be useful: [ ...
>>]
>>>>> nobr = re.compile('\W*<br.*?>\W*', re.I)
>
> Agreed (on both counts), but r'\s*<br.*?>\s*' might be better
> (consider what happens with "an unfortunate... <br> in the middle"
> if you use \W rather than \s).
>
Yes, I don't really know why I wrote \W when I obviously meant \s. Thanks
for correcting that.
Even better might be r'(\s*<br.*?>)+\s*' to get multiple runs of <br> tags.
More information about the Python-list
mailing list