Thread: Regex examples
View Single Post
Old 04-16-2020, 05:57 PM   #628
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by Mister L View Post
I want to find sets of em dashes with some text between them that are in the *same sentence*. So the text between the em dashes cannot include .!? but can include ,;: for example.
Did you mean sets of EN dashes instead? (Like your examples use?)

Something like this might work:

Find: –(\w*[^\.\?!]+?)–
Replace: —\1—

That would replace the en dashes with em dashes, and stick the captured "non-sentence" back in the middle.

I didn't do thorough testing though, so it probably would break in a lot of edge cases, but it did work correctly on your examples.
Tex2002ans is offline   Reply With Quote