By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,930 Members | 2,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,930 IT Pros & Developers. It's quick & easy.

Regexp to enclose text with P-tag

P: n/a
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? :)
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.