grep search expression

Home Forums General InDesign Topics grep search expression

Tagged: 

This topic contains 5 replies, has 4 voices, and was last updated by  Anonymous 6 months, 3 weeks ago.

  • Author
    Posts
  • #67371

    Terrence
    Member

    HI all

    Anyone out there know the quick GREP search terms for finding an apostrophe followed by a space then an uppercase letter?

  • #67375

    Terrence
    Member

    By jiggitty, give it up to the GREP newbie. I think I figured it out:

    ‘\s\u

    This came in handy: http://indesignsecrets.com/grep-and-text-metacharacter-cheat-sheet.php

    .’\s\u apparently searches for any punctuation followed by an apostrophe followed by a space then an uppercase letter. It is finding instances where this happens between paragraphs, but I don’t mind.

  • #67446

    Hi All,
    I’m trying to write a grep to convert improperly styled times on a calendar to the proper style.
    I want the grep to find “am.” and change it to “a.m.”
    But since there is the possibility of having an “am.” being part of a show title such as “Sam I am.” I wanted to use a look behind to exclude an “am.” that is preceded by an “I” and a blank space.

    The negative lookbehind grep I was writing looks like this:
    \s(am\.)(?<!I\s)

    I also tried a positive lookbehind for an am. preceded by a space and a digit to narrow the types of am.s that could be selected
    \s(am\.)(?<=\d)

    The first one still selects the “am.” following the “I” and the space.
    The second selects nothing.
    Any ideas on how to use a lookbehind to select only the “am.” following a digit and a space?

    • #67516

      Steve Jenks
      Member

      Hi Milt

      I think it could be as simple as ignoring the look behinds and simply searching for any occurrence of a digit followed by a space followed by ‘am.’

      If this is the case then if you searched
      (\d )(am.)

      and replaced with
      $1a.m.

      It should change just the times and leave the rest alone.

      Steve

  • #67520

    Thanks for the reply, Steve.

    This is what I ended up writing that worked:

    (?<=\d)am\.|(?<=\d/s)am\.|(?<=\d)am(?=\,)|(?<=\d/s)am(?=\,)|(?<=\d)am(?=\-)|(?<=\d/s)am(?=\-)|(?<=\d)am(?= *)|(?<=\d\s)am(?= *)|(?<=\d)am(?=\;)|(?<=\d\s)am(?=\;)

    then replace with “a.m.”

    It picks up every variation of the incorrect “am”s

    • #67536

      Anonymous

      Glad you got it sorted Milt.

You must be logged in to reply to this topic.