5 Replies Latest reply on May 18, 2017 9:06 AM by r5dsign

    Help with GREP Expression

    r5dsign

      Hello,

      I am trying to make an expression with GREP where I need to make some text non-italic. I've marked them red for viewing purposes (per screenshot below). I created the first expression where the opening parenthesis and the word "Now" and the space after it are non-italic. I also made the closing parenthesis non-italic. However, it is also changing single letters like lower case "o" and "w." How can I keep the expression from non-italicizing those single letters? I also, need to non-italicize words like "and", "var.", and "ssp." I probably need to create separate GREP styles for those words as well, but any advice would be greatly appreciated.

       

      Screen Shot 2017-05-17 at 11.17.30 AM.png

        • 1. Re: Help with GREP Expression
          Heric Dehon Level 1

          I belive your are trying to "find" these expressions in bold -> (Now and )

           

          I'm not a GREP expert but you can try these. I'll also wait a better code

           

          ((\()Now)|(\))

          • 2. Re: Help with GREP Expression
            winterm Level 4

            Pretty straightforward, but should do the trick? (not thoroughly tested):

            \(Now\h|\band\h|ssp.\h?|var.\h?|\)

            • 3. Re: Help with GREP Expression
              r5dsign Level 1

              Thank you so much for the advice folks. Winterm's expression did the trick for what I was trying to accomplish!!

              • 4. Re: Help with GREP Expression
                [Jongware] Most Valuable Participant

                Just so you know what went wrong in your own attempt:

                 

                Square brackets indicate that all characters inside form a custom character group, of which only one must match. This is equivalent to the shortcut notations \d for any single digit, which you can also express as [0-9] (or the longer [0123456789]), and \u and \l, which can be used for [A-Z] and [a-z] respectively (not limited to just these; both also match way more characters, such as accented, Greek, and Cyrillic).

                 

                You matched only one single character out of the set "(", "N", "o", "w", " ", and ")". It appears to work for "(Now)", but only because each match consisted of one single character -- it's just that it did so in 5 consecutive matches.

                 

                winterm's GREP consists of whole words, separated by "OR"  | so it indeed reads as "(Now" OR "and" OR .. etc. The code "\h" stands for 'any horizontal space', so it matches a single regular space but also any of its fixed width variants as well as en- and em-spaces. The "\b" before "and" is to force a 'word break' before, that is, it should match 'and' but not 'hand', 'land', or 'ampersand'.

                • 5. Re: Help with GREP Expression
                  r5dsign Level 1

                  Really appreciate the explanation of what I did wrong and now correct answer makes more sense.

                  Thank Y'All for your reponses!