Regexp to enclose text with P-tag

S

SubZane

I'm looking for help writing a regexp to enclose text with a <p> tag.
The rule is that other HTML tags in the text like <img> and other
block elements should NOT be enclosed by <p>.
example:

lorem ipsum <img src="image.gif" />dolor

should become:

<p>lorem ipsum</p><img src="image.gif" /><p>dolor</p>

Can anyone help me with this? :)
 
H

Heiko Wundram

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top