Quote:
Originally Posted by SilvioTO
I would like to use regex to find the following error in my book:
«dialogue (missing » at the end of phrase).
correct string:
«dialogue»
|
This is the Regex I used for many years:
Search: (“[^”\r\n]*)</p>
Instead of using LEFT/RIGHT DOUBLE QUOTES, substitute whatever quotations you need for your language.
In your case, you'll use left/right guillemets:
Search: («[^»\r\n]*)</p>
This will catch lines 1+3:
Code:
<p>«This is a test.</p>
<p>And this is more «This is a test.» And more.</p>
<p>Testing. «This is a test.</p>
<p>«This is a test.»</p>
but skip 2+4.
- - -
Side Note: Nowadays, I use Toxaris's
EPUB Tools + "Dialogue Check", which is/was the ultimate way to catch all quotation mark errors. I wrote about it in detail back in:
While the pure regex method works in
most cases, it will not work on heavily nested (or mismatched) quotation marks.
To catch
all left/right or outer/inner quotation mark errors, you definitely need something more smart that:
- goes forwards/backwards.
- Catching really hard cases + paragraphs with multiple sets of dialogue.
- handles false positives like apostrophes vs. SINGLE QUOTES.
For a little more info on that, see my post in:
Sadly, Toxaris's EPUB Tools only works in Microsoft Word... and as of a few years ago, Toxaris stopped maintaining it + his site went down.
I did save a copy + attach it to this 2022 post though.
- - -
Quote:
Originally Posted by SilvioTO
Tried some code, but I only be able to find a text between « and ».
|
Heh, I wrote about that in detail too:
If you ever needed to catch/tag all dialogue in a book for some reason, there's your answer too.