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

Beginner GREP Question

Tagged: 

Return to Member Forum

  • Author
    Posts
    • #117075
      Ian Freeman-Lee
      Participant

      Hello! I’ve been getting into GREP styles finally, and they are super freaking cool. Can’t believe I put it off all these years.

      I have successfully gotten a style working which applies my character style to any text before a “:” character IF a “:” exists in the paragraph. This is the style: .+?(?=:)

      My question is: is it possible to make this even smarter and only apply the character style to the first set of characters followed by a colon? Right now if the paragraph contains a second colon somewhere it will apply my character style to all the text up to that second colon instead of up until the first one.

    • #117076
      David Blatner
      Keymaster

      Congrats on getting into GREP, Ian!
      Yes, you can start the expression with a caret ^ to force it to start at the beginning of the paragraph.

    • #117139
      Ian Freeman-Lee
      Participant

      Hey David, thanks so much for the reply! What you suggested worked, but I don’t totally understand why it worked. I now understand that ^ means start of the paragraph, but what does GREP do if you don’t have that there? Is it starting from the end instead?

    • #117151
      Jeremy Howard
      Participant

      Hello Ian,

      When you include “^” in your expression, you are basically anchoring the expression to a specific point on the front end. Before you added that part to your expression, the GREP was searching more generally and essentially looking for any characters that appear before “:” at any point, anywhere in your text.

      Make sense?

    • #117153
      Ian Freeman-Lee
      Participant

      Aw, OK. That does make sense, thanks. I had been wondering how it parsed everything, so that actually answers more questions than just this one!

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