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: Find X if followed by Y but not if Y is followed by Z?

Return to Member Forum

  • Author
    Posts
    • #63727
      Missy
      Member

      I need to turn this:

      The SERVICE Screen is accessed by pressing the SERVICE SCREEN button on the MAIN Screen. (Sometimes the “S” in screen is lowercase)

      into this:

      The Service screen is accessed by pressing the SERVICE SCREEN button on the Main screen.

      I have a GREP that will find the ALL CAPS words:

      /<[A-Z]{2,}>

      And I have one to find all the instances of “Screen” not followed by the word “button”:

      Screen(?! button)

      But how do I find an ALL CAPS word followed by the word “Screen” (with or without a capital S) that is NOT followed by the word “button”?

      I would also like the Change to: format if someone knows.

      My head hurts.

      Missy

    • #63728

      Strangley enough, you can nest positive and negative lookaheads!

      In steps: find All Caps with bu{2,}

      followed by “[Ss]creen” (uppercase or lowercase 's'), we get

      bu{2,}(?=s[Ss]creen)

      (I'm assuming you want a space in between) but then not followed by “button”, which is (?!sbutton):

      bu{2,}(?=s[Ss]creen(?!sbutton))

      Note how the negative lookahead for “button” is inside the positive lookahead for “screen”. (The trick to insert in this editor is to insert them twice: \.)

      Now for the bad news…

      I would also like the Change to: format if someone knows.

      Often asked, but unfortunately InDesign's GREP cannot automatically change uppercase to lowercase, or the reverse.

    • #63733
      Missy
      Member

      Thank you so much Jongware.

      Wonder when Adobe will put in the case feature. It seems like a no-brainer.

      Ah, Adobe.

      Thanks again!

      Missy

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