Thread: Regex examples
View Single Post
Old 02-21-2012, 08:07 AM   #17
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 18,823
Karma: 97805504
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by Jellby View Post
So you want something like this?

Code:
<span class="italics">[^<]*\s.*</span>
It might not be the right regex dialect, but [^<] is intended to mean "any character not <". That won't match instances where there is something nested in the <span> before the first space, but those should be rare, and can be looked for afterwards.
That seems to be the ticket. Thanks!

I had a mishap where an ill-thought-out global replace (because of nested spans and greedy expressions) left me with a boatload of long, incorrectly italicized passages. And it got saved before I caught it. I could've backed up a few revisions and started over, but I didn't want to ( maybe not always straight, but ever forward ).

Anyway, since I know the one word occurrences aren't mistakes, I can safely skip those. And in this particular document... that little regex expression knocks the number of occurrences I have to manually proof against the original text from 700+ down to around 150.

Thanks again!
DiapDealer is offline   Reply With Quote