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 ital between commas if it contains an ' and two numbers

Tagged: 

Return to Member Forum

  • Author
    Posts
    • #56180
      Cindy Kelley
      Participant

      Hi grep geeks,

      I design a magazine for a fraternity that always list a members name followed by a comma, the school they attended and then an single right apostrophe before two digits indicating the year they graduated.

      There are hundreds of these in the magazine and it seems I always miss a dozen or so in my formatting :(

      Example:

      While attending school, John Doe, Northern Iowa '80, accomplished blah blah blah

      I did set up nested styles when the names are in a big list (usually stating who gave how much money), but the instances appear inside paragraphs, I usually have to hunt and change.

      hugs to anyone who can help me out

      thx

      cindy in indy

    • #56182

      You know, I'll let you off on the “geek” because I'm looking forward to the hugs! That is, if this GREP style works for you:

      (?<=,)[^,]*~]dd(?!d)[^,]*(?=,)

      It comes with a few features:

      1. It'll start and end at comma's but will not include them into the italics. I usually do it like that because it's typographically correct, in this use, but feel free to scream if you want them italicized anyway.
      2. It does not react to a straight ' before the year, only for the correct character: ’ (the Right Single Quotation Mark). That's the correct character to use; but if you're willing to dispense more hugs, I could make it check for the straight quote as well (just in case some are correct and some are not).
      3. It'll only work when the year has exactly two digits. Try it; the italics will switch off when you accidentally type '1980 or '078 or something like that.

      So this GREP is hyper-correct, but don't worry, I can have it relax a bit if you want me to.

    • #56184
      Cindy Kelley
      Participant

      yes, hugs hugs hugs

      sorry about the “geek” thing. it was a compliment. i love geeks :)

      i ran the grep and it worked!!!

      it found the text i needed, and i love that you didnt include the commas. xxoo. and not finding a straight ' is fine too since i dont think my editor knows how to make one if she tried ;).

      the style also found

      , an ’80s mixer with Alpha Psi Fraternity and bowling with Tau Kappa Epsilon Fraternity.—Natalie,

      which isn't a big deal since i will probably use Change/Find rather than Change All to be safe

      xtra hugs

    • #56185

      Ah, you're using Find & Change because there just may be oddball sentences. Yeah, GREP styles are great in applying your styles everywhere that fulfill the requirements, but there is no easy way of having it ignore one particular sentence …

      Just FYI, your '80s mixer can be ignored in three ways. You might want to give either a try if you are finding too much false matches.

      First one is adding the period to the 'scan-for-end-of-italics' command. In effect, nothing may follow the digits except a comma or period, and only if it's then followed by a comma, it's a good match (i.e., comparing will end on the next comma or period, and only if there is a comma it's “good”).

      (?<=,)[^,]*~]dd(?!d)[^,.]*(?=,)

      The other method relies on the difference in the year notation: the two digits must be followed by a space or a comma, like this:

      (?<=,)[^,]*~]dd(?=[,s])[^,]*(?=,)

      Also, if the year is always immediately followed by the ending comma, as in your original example, this is the most simplest case:

      (?<=,)[^,]*~]dd(?=,)

      which will effectively only match comma, all other stuff except comma's, year, comma (and exclude the comma's at start and end).

    • #89454
      Jennifer Morrow
      Participant

      I know that this is an old post but I am doing the exact same thing (fraternity magazine, same format). I tried pasting in the GREP expression solution provided and it didn’t work for me. I am trying to figure out what I might have done wrong. I added it to my main body paragraph style so that it catches each instance so that I don’t have to worry about a find and replace later.

      I had created a GREP expression that worked but only if there is one word (school). In other words, if the school was Ohio, ’11, the school and year became italicized but if it were Ohio State, ’11, then it ignores it. Obviously, I want it to work for both.

      Here is the solution I came up with: (,)(\w+~]\d+)(,) I am still rather new to GREP so I am sure it can be written cleaner.

      Any help would be most appreciated.

    • #89468
      Jennifer Morrow
      Participant

      Okay, I figured it out. This is what worked. I might have done the happy dance. :)
      (?<=,)[\w]+~]\d+(?=,)

    • #89475

      If i helps, I like to make some GREPs in styles to highlight common mistakes according to the magazine standard, like in “10am”, “10a.m.”, “10 am” or “10 a.m.”. Or even “US$40”, “$40” or “US$ 40”.

      If I see something highlighted in yellow in the middle of the text I already know I need to correct.

    • #89593
      Jennifer Morrow
      Participant

      That is a great tip. I’ll add that to my styles too. Less hunting and pecking and having more fun designing. :)

    • #89594

      If it helps, I use those:

      No Break:
      .{15}$
      (?i)(http|ftp|www)(\S+)|(\S+) (\.gov|\.us|\.net|\.com|\.edu|\.org|\.biz)
      (\d)( am|am| pm|pm)

      Yellow highlight:
      \d+ dollars
      (\d)( a.m.|a.m.|am| p.m.|p.m.|pm)

    • #89595
      Jennifer Morrow
      Participant

      Oh, thank you. Copying and pasting into my “most used styles” document.

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