Thread: Regex examples
View Single Post
Old 04-16-2020, 10:02 PM   #630
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
Now that I see the result I understand it but I don't think I would have come up with it on my own so it's a good thing I asked for help. This should save me quite a bit of time. Today I was working on a book that had over 400 dashes in it and that's not even the record so you can see why I'd want to optimise my searches.
Definitely don't ever do a Replace All with something like that though, you won't know what sort of rogue madness might happen. (And I didn't test on an odd number of en dashes.)

Quote:
Originally Posted by Mister L View Post
I don't need to replace the dashes, I need to replace the spaces actually (in French we use non-breaking spaces with dashes but depending where the dash is the space goes either in front or in back so you can't just do "replace all"), but the "not a sentence" part is what was giving me trouble. Some authors like to sprinkle those things around like there was no other punctuation and you can have multiple dashes in one paragraph and not all of them are sets.
Find: – (\w*[^\.\?!]+?) –
Replace: – \1 –

Hopefully it works, and it will at least save you a lot of time. The rest can probably then be found with a simple:

Find: – <--- Put a space before or after the en dash
Tex2002ans is offline   Reply With Quote