-1

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

  • What is a "left" and "right quote mark"? Your regex is [malformed](https://regex101.com/r/5q9LQO/1). – Wiktor Stribiżew May 21 '21 at 15:27
  • Left is an opening and right is a closing quote mark. InDesign calls them 'single left quote mark' and 'single right quote mark'. What's wrong with the regex? The right parentheses is closing the negative lookahead expression – Daniel James Smith May 21 '21 at 15:34
  • Your `[` starts a character class, and `(` is inside it. So the last `)` is not paired. Please create a regex demo from the link I provided in the first comment. Do not use your special terminology. If you want to match 230 chars from `~[` substring but avoid matching if there is `~]` substring, just say that. I still have no clue what you mean saying "closing quote mark". – Wiktor Stribiżew May 21 '21 at 15:36
  • No. ~[ is the GREP for an opening parentheses and ~] is the GREP for a closing parentheses – Daniel James Smith May 21 '21 at 15:40
  • No, `\[` is the regex to match `[`. And `]` will match `]`. So do you want `\[.{230}(?!])`? or `\[[^\[\]]{230}(?!])`? Or what is the pattern you need to match? – Wiktor Stribiżew May 21 '21 at 15:42
  • Well, it's the code that InDesign automatically adds when you ask for an opening and closing apostrophe so I think we're talking at cross purposes. Do you use InDesign? Sorry, I meant opening and closing apostrophe in above comment: ~[ is the GREP for an opening apostrophe and ~] is the GREP for a closing apostrophe – Daniel James Smith May 21 '21 at 15:45
  • I don't think the demo in your link uses the same type of code as InDesign – Daniel James Smith May 21 '21 at 15:51
  • Then why do you use lookaheads, limiting quantifiers if you are not using a regex? – Wiktor Stribiżew May 21 '21 at 15:52
  • InDesign's GREP is just a bit different from what I've gathered over various posts on here. For example: https://stackoverflow.com/questions/35068678/use-regex-to-match-certain-number-of-lines-that-follow-the-line-containing-the-o – Daniel James Smith May 21 '21 at 16:02
  • I assume you're not worried about multi-paragraph quotes? – Neil May 21 '21 at 17:20
  • @ Neil. Damn, I hadn't thought of that. I'm not sure there's any way of finding those too – Daniel James Smith May 26 '21 at 10:09

1 Answers1

0

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).