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 Question: Lookbehind? Lookahead? Help!

Return to Member Forum

  • Author
    Posts
    • #1221022
      Drew Bingham
      Participant

      Hi there! I’m trying to apply a GREP style to a series of terms and I’m having a hard time wrapping my head around it. I’m trying to isolate the vowels in the phrase “short a,” “short e,” “short i,” etc. I want to make a style that will italicize the “a,” “e, “i,” etc.

      I’ve tried using positive/negative lookbehind/lookahead, but I can’t seem to get it to work. Still fairly new to GREP. Any tips?

      For additional context, I WAS able to make essentially the reverse work, targeting the first letter in terms like “L-Blends,” or “R-Blends” and make those italic with [\u]+(?=-Blend)

      Any info is greatly appreciated. Thanks!

    • #14323342
      Drew Bingham
      Participant

      I figured it out! Woot!

      Just in case anyone is curious, this is what worked for me:

      (?<=short)(a|e|i|o|u)

    • #14323341
      David Popham
      Participant

      Another option is (?<=short)[aeioi].

      Also, if there is a particular character that always follows the vowel, such as a space or punctuation mark, you may want to include that in your expression to prevent non-wanted italicization from occurring, such as the “a” in the phrase “short and sweet.”

    • #14323340
      Drew Bingham
      Participant

      Awesome tip, thank you!

    • #14323335

      To prevent more than a single letter being matched, add a word break after your vowel:

      (?<=short)[aeiou]

      But – rather than using a GREP Style for this, I’d recommend a plain (GREP) find & change. It’s way easier to correct if you want to exclude a few occurrences, and I recommend “sticky” formatting for stuff that needs it, reserving GREP styles for stylistics only.

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