Skip to main content
danielw42205661
Known Participant
March 14, 2024
Answered

Grep help please

  • March 14, 2024
  • 2 replies
  • 392 views

Having a problem trying to apply bold char style to instances of text between parenthesis and quotations e.g ("xyz")

 

Grep expression I've used is: (?<=\(“).*(?=”\))

 

It works partially but when there is more than one instance in a paragraph it is not working as intended and highlights more than intended. Screenshot below showing this situation. Can someone please tell me what expression should be used to correct this? Thanks.

 

This topic has been closed for replies.
Correct answer jmlevy

Change your GREP query to this one:

(?<=\(“).+?(?=”\)) instead of *

In English, it should be “one or more times (shortest match)”

2 replies

Robert at ID-Tasker
Legend
March 14, 2024

@danielw42205661 

 

GREP, by default, is "greedy".

 

"?" in @jmlevy reply makes it "non-greedy" / "lazy" - so GREP will be looking for the "shortest match".

 

danielw42205661
Known Participant
March 14, 2024

Thanks Robert, good to know 🙂

jmlevy
Community Expert
jmlevyCommunity ExpertCorrect answer
Community Expert
March 14, 2024

Change your GREP query to this one:

(?<=\(“).+?(?=”\)) instead of *

In English, it should be “one or more times (shortest match)”

danielw42205661
Known Participant
March 14, 2024

Thanks!