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 Style Expression Help Neede

Return to Member Forum

  • Author
    Posts
    • #1196613

      Hi GREPsters, I love the convenience of GREP styles, but the syntax drives me bonkers, so I’m appealing to the experts. I need to apply a different character style to any text AFTER a price, or more specifically lowercase o|t|f. What’s the syntax to ignore anything before the price, Another way to look at it would be to start at the END of the paragraph and format everything until you hit a digit. Thanks!

    • #14323715
      Aaron Troia
      Participant

      John,

      You could try positive lookbehinds but I think the best way would to use Keep (/K) which acts like a positive lookbehind but is nongreedy.

      Aaron

    • #14323714

      Thanks Aaron, where does (/K) go in the GREP string? Like this?: \$*.* o|t|f(/K)

    • #14323713
      Aaron Troia
      Participant

      I would do \$\d+?\.\d+?\Ko|t|f which should ignore the dollar sign, the decimal, any digits before and after the decimal, and the space after and only apply the character style to o|t|f

      also sorry for the wrong syntax for Keep, I meant to write \K in my previous post

    • #14323712

      Thanks Aaron, it’s closer, but still no cigar. Using that GREP, if there is a t or f before the price, the style is changed, but not the o. After the price, the t and f change as I want, but not the o.

    • #14323711
      Aaron Troia
      Participant

      Hey John,

      Oh you’re right, I think I should have wrapped the letters after the price in parenthesis \$\d+?\.\d+?\K(o|t|f) that at least fixes it on my end.

    • #14323704

      Thanks so much Aaron, this will work in 95% of the cases. However, in those rare instances where there is more than one character after the price, only the first character is reformatted. I thought changing (o|t|f) to (?+) would solve this but it didn’t.

    • #14323700

      Aaron is definitely on the right track this far, but it looks like we’re going to need to see some actual examples here.

    • #14323693
      Jeremy Howard
      Participant

      This may be what you are looking for:

      \$\d+?\.\d+?\K(o|t|f)(\w+)?

      I just added “(\w+)?” to the end of the GREP expression that Aaron Troia posted.

      The Breakdown:
      “\w” = any word character
      “+” = one or more times
      “(” & “)” = enclosing an expression the create a “captured group”
      “?” = may or may not exist.

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