Thread: Regex examples
View Single Post
Old 08-31-2014, 11:51 AM   #409
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 7,480
Karma: 13105019
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by DiapDealer View Post
Which would exclude paragraphs that had no attributes. Why not:
Code:
((Mr|Mrs|Dr|other)\.)</p>\s*<p[^>]*?>
Replace:
Code:
\1
(space after the 1)
instead?
Reread my regex. I did think of that.

Nitpick: I used an optional capture group, which includes a space (because as a general idea, I like demanding spaces after the tag name and before the attribute, to avoid matching the wrong tags) -- but your regex does not need a ? because the star already covers that.

Last edited by eschwartz; 08-31-2014 at 11:57 AM.
eschwartz is offline   Reply With Quote