Thread: Regex examples
View Single Post
Old 08-31-2014, 10: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.
 
Posts: 5,981
Karma: 9379756
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch (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 10:57 AM.
eschwartz is online now   Reply With Quote