Regexp to enclose text with P-tag

Heiko Wundram heikowu at ceosg.de
Tue May 18 09:09:34 EDT 2004


Am Dienstag, 18. Mai 2004 14:58 schrieb SubZane:
> lorem ipsum <img src="image.gif" />dolor
>
> should become:
>
> <p>lorem ipsum</p><img src="image.gif" /><p>dolor</p>

As far as I can see, there's no way to do this using Regexps... What you'd 
better do is parse the HTML using sgmllib, and on continuous data sections 
just output <p> <yourdata> </p>, and output each start/stop tag as it was in 
the sources.

HTH!

Heiko.




More information about the Python-list mailing list