Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

GREP to find any sentence with a list sep by commas & missing comma before "and"

Return to Member Forum

  • Author
    Posts
    • #87081
      Olaf Nelson
      Member

      The author of a book I’m working on wants to use the Oxford comma but didn’t do so consistently.
      So I either have to search for every “and” (and “or”) in the book and see if it’s in a list of more than two things, or I need to come up with a grep for it.
      Examples:
      apples, 14 kinds of bananas, trilobites and fuel pumps (needs comma after trilobites)

      the problem with cheese, Albert’s “cousin” and liver (needs comma before the ” at the end of cousin)

      the problem with cheese, Albert’s “cousin” and liver and onions (needs comma at the end of cousin but NOT after liver)

      I’m fine with having to look at each one as if finds them–in fact it’s imperative since there are so many ways it can vary. I just want to find:
      any text followed by a comma that’s followed by more text that’s followed by “and” or “or” and is all within the same sentence (so doesn’t span any period or question mark).

      Nothing I’ve tried so far has worked. Hoping someone has a better grip on grep than I do.
      Thanks.

    • #87090

      First of all, I can recommend the “Highlight GREP-Skript” from Roland Dreger: https://www.rolanddreger.net/de/249/highlight-grep-in-indesign/#
      Here you can see all founds in your document, without moving step by step.

      To find only the word before comma …
      \w+(?=,.+(and|or).+?[.?])

      To find the whole sentence:
      \w+,.+(and|or).+?[.?]

      best
      Kai

Viewing 1 reply thread
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads