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

Locating the start of a sentence with GREP

Return to Member Forum

  • Author
    Posts
    • #78066
      Chris Court
      Member

      Hey GREP gurus, I’m attempting to detect whether a letter is at the start of a sentence or not. It SEEMS as if this should be a simple task, but it’s been giving me a headache for days.

      For the sake of simplicity, let’s assume a sentence will always begin in one of two ways. 1) Immediately following the beginning of a paragraph, or 2) immediately following a period-space.

      I can find the first case using: ^\K\u
      I can find the second case using: \. \K\u
      but when I try to combine these: (^|\. )\K\u It only gives me the same result as the first case GREP, above, ignoring the second case.

      What am I doing wrong?

      Thanks for any suggestion!

      Chris

    • #78088
      Peter Kahrel
      Participant

      The problem is that unlike many other programs, InDesign isn’t very good at finding locations such as ^ and $ on their own. You can’t replace $ with e.g. ) to insert a parenthesis at the end of the paragraph.

      Seems to me that the only way you can get your grep to work is using (\r|\. )\K\u which assumes that a capital after a \r is the beginning of a sentence. You miss the first sentence in a story though.

      Peter

    • #78097
      Chris Court
      Member

      Thanks for the explanation and suggestion, Peter. Every time I think I’m just getting a grip on GREP, something like this comes along and trips me up. All part of the fun :-D

      C

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