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

Advanced GREP Statement – This one is a doozy. Can anyone help?

Return to Member Forum

  • Author
    Posts
    • #61788
      kingsigma
      Member

      Hey All, I am new to GREP, and so far I have been getting along very well. However, I may have bit off more than I can chew with this one statement. Here is what I need the copy to look like:

      W Sec. 1: Thurs. 6–9.30 p.m., June 7–28 (4 sessions). Jonathan Schnapp, developer and president, Schnapp Studio Inc.
      L Sec. 2: Sat. 9.30 a.m.–5.30 p.m., June 30–July 7 Claudia Uscategui, on-site design consultant, Arup Americas.
      W Sec. 1: Sat. 9 a.m.–4 p.m., June 2–9 (2 sessions). Marc A. Thorpe, founder and principal, Third Eye Studios; Susan J. Slotkis, designer and sole proprietor, Profiles-Personalized Interiors
      M Sec. 1: Wed. 6–9.30 p.m., July 11–Aug. 1 (4 sessions). Sharon “Libby” Clarke, Sigma Studios

      You'll notice that the names are roman, but everything else is italic. Plus, the letters in the beginning are in bold. Here is the GREP I wrote so far:

      Apply Style: Roman

      (?<=[).s]|[d+s]|[;s])([lu]+)( )([.*?)?([lu]+)([. ]?)( )?([lu]+)

      Apply Style: No Break

      (u[lu]+)( |~s|~S)(d+)(~_|~=|~~|-)(d+|(u[lu]+)(.?)( |~S)(d+))

      Apply Style: Bold

      ^([lu]?)

      Apply Style: No Break

      (().+?())

      Apply Style: No Break

      (.){15}$

      Everything seems to be working except for the names being properly changed to roman. I thought I planned out for every possible scenario, but for some reason, it doesn't always work correctly. Does anyone have any suggestions? Thanks in advance for your help.

    • #61791

      All backslashes disappeared in your post (the forum editor makes single backslashes disappear; you need to type in two \ to get a single — and yes, I actually typed “” to get those two “\”) but on first sight I think the Romanization may not be working because of this bolded part (backslashes inserted where I thought appropriate):

      Apply Style: Roman

      (?<=[).s]|[d+s]|[;s])([lu]+)( )([.*?)?([lu]+)([. ]?)( )?([lu]+)

      First of all you need to re-write it without the + (it's kinda hard to understand exactly what the entire expression does ;) ) because as it stands it would do “nothing” because the '+' is ignored anyway inside a [..] bracketed section. It just adds the '+' to the list of 'allowed' characters. But putting the '+' outside the brackets is no good either, since every test inside a single lookbehind needs to have the same net length, and you cannot use variable lengths at all.

      Can you further pin-point the exact point of the expression where it fails? A good way to check what expression does what is disabling all of them but one. All you need to do is insert an invalid command at the very start — having a '*' there is invalid and will effectively kick the entire further expression out of the loop. To visually verify the expression works as expected, add this to the character style: Underline on, 12 pt thick, offset -3 pt, color Full RGB Green. That will highlight the applied style just nice.

    • #61792

      Pff :D

      Here is my take on it–it's a bit unusual as it needs to test every month name. First, you add “Italics” to the entire paragraph style. Then make everything from the start up to and including the speaker's name Roman. Finally, make everything from the start UP TO (and stopping at) the speaker's name back Italics again — this is the same as the previous one except for the very last command sequence (which in addition romanizes everything up to, but excluding, the very first comma).

      Roman:

      ^.+(June|July|Aug.) d+(~=d+)?( (d+ sessions?).)?[^,]+

      Italics:

      ^.+(June|July|Aug.) d+(~=d+)?( (d+ sessions?).)?

      Roman again: (for 2nd and further names after “;”)

      (?<=; )[^,]+

      To make it work for every month you have to add them all :) (But ain't it wonderful that if you do so once, InDesign will do the rest entirely on its own?)

      Below these three you can add your other GREP styles to embolden and no-break the various parts — I didn't test those but at a glance I'd say they ought not to interfere with the above ones.

      (You are “new to GREP”? Hah! you are giving it a very good first go!)

    • #63735
      kingsigma
      Member

      Hey, Thanks Jongware. I guess I am new to forums too, because I forgot all about this question I asked in March! Thanks for the repsonse. I am back on this project again for another issue of the booklet, so I will try this code now. I appreciate it!

      Brad

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