1

I need a way of finding long quotes which don't preclude long quotes containing an apostrophe s. This is my code:

‘.{250,}(?=[\.’])(?=[,’])(?=[\?’])(?=[!’])

See this regex demo.

There are two long quotes (one with a possessive apostrophe s) and one short quote and it finds both long quotes. But in InDesign it just finds any 250 characters preceded by an apostrophe (it ignores the full point, question mark, comma, and exclamation mark). I think this is because it's only looking at a single character in the positive lookbehind. Is there a way of getting it to look for both characters?

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
  • 1
    Something like `‘.{250,}(?=[.,?!]’)`? – Wiktor Stribiżew May 25 '21 at 11:17
  • @Wiktor Stribiżew Thanks, but that finds groups of short quotes as well as long quotes. I need to somehow preclude the short quotes. https://regex101.com/r/Um2Ylb/1 I guess I need to somehow preclude ‘ from the search after the initial ‘ – Daniel James Smith May 25 '21 at 11:38
  • What does it mean: "preclude the short quotes"? Regex either *matches* some text or not. – Wiktor Stribiżew May 25 '21 at 11:40
  • So I want to find all 250+ characters between quote marks not including further opening quotes (the first character in your code ) This would be easier if I could paste the characters as code but that's not working for some reason. 'So this is a short quote' 'This is a long quote. This is a long quote. This is a long quote. This is a long quote. This is a long quote. This is a long quote. This is a long quote. This is a long quote. This is a long quote. This is a long quote. This is a long quote. This is a long quote. This is a long quote. This is a long quote. This is a long quote.' – Daniel James Smith May 25 '21 at 11:45
  • 1
    Then use a negated character class, `[^‘]`, see `‘[^‘]{250,}[.,?!]’` [demo](https://regex101.com/r/Um2Ylb/2). – Wiktor Stribiżew May 25 '21 at 11:49

1 Answers1

1

You can use

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

See the regex demo.

Details

  • - a char
  • [^‘]{250,} - 250 or more chars other than , as many as possible (NOTE: this matches across lines. If you need to limit matching to the current line only, add line break chars into the negated character class, [^‘\r\n]{250,})
  • [.,?!] - a ., ,, ? or ! char
  • - a char.
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563