View Single Post
Old 04-22-2023, 08:35 PM   #8
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 SilvioTO View Post
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.
    • Saving tons of time.

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 View Post
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.

Last edited by Tex2002ans; 04-22-2023 at 09:00 PM.
Tex2002ans is offline   Reply With Quote