Search code examples
grepadobe-indesign

GREP to find long quotes in text


I'm trying to find long quotes in the text that I'm editing so that I can apply a different style to them. I've tried this GREP:

~[.{230}(?!.~])

What I need is for the GREP to find any 230 characters preceded by a left quote mark, not including any 230-character sequence including a character followed by a right quote mark. This should then eliminate quotes of less than 230 characters from the search. My GREP finds the correct length sequence but doesn't exclude those sequences which include a right quote mark.

So I want to find this, which my GREP does:

enter image description here

But not this, which my GREP also finds:

enter image description here

Because it has a closing quote in it and is therefore what I'm classing as a short quote.

Any ideas? TIA


Solution

  • It took me a while to figure out how to express this in a way that would suit my purposes. Wiktor Stribiżew came up with the code:

    ‘[^‘]{260,}[.,?!]’
    

    Find opening quote but no more opening quotes (to preclude multiple short quotes) followed by 260 or more characters (about five lines in my text which is the point at which a long quote should be formatted as a broken off quote) ending with either a full point, comma, question mark, or exclamation mark AND a closing quote (I've included the punctuation marks as well as the closing quote rather than just a closing quote because otherwise it will see a possessive apostrophe as the end of the quote).

    All thanks to Wiktor Stribiżew for the code!

    Edit, Neil is correct this code won't find multiparagraph long quotes. But I can run:

    ‘[^’]{150,}~b‘
    

    which will find any multiparagraph quotes (doesn't work in the Regex demo but does in InDesign for some reason).