• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help with GREP Expression

Participant ,
May 17, 2017 May 17, 2017

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.

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

Views

436

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , May 17, 2017 May 17, 2017

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

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

Votes

Translate

Translate
Explorer ,
May 17, 2017 May 17, 2017

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)|(\))

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 17, 2017 May 17, 2017

Copy link to clipboard

Copied

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

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 17, 2017 May 17, 2017

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!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2017 May 18, 2017

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'.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 18, 2017 May 18, 2017

Copy link to clipboard

Copied

LATEST

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

Thank Y'All for your reponses!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines