Copy link to clipboard
Copied
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.
Pretty straightforward, but should do the trick? (not thoroughly tested):
\(Now\h|\band\h|ssp.\h?|var.\h?|\)
Copy link to clipboard
Copied
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)|(\))
Copy link to clipboard
Copied
Pretty straightforward, but should do the trick? (not thoroughly tested):
\(Now\h|\band\h|ssp.\h?|var.\h?|\)
Copy link to clipboard
Copied
Thank you so much for the advice folks. Winterm's expression did the trick for what I was trying to accomplish!!
Copy link to clipboard
Copied
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'.
Copy link to clipboard
Copied
Really appreciate the explanation of what I did wrong and now correct answer makes more sense.
Thank Y'All for your reponses!