Skip to main content
Rocket95
Known Participant
March 19, 2015
Answered

Escaping the open & closed parenthesis characters

  • March 19, 2015
  • 1 reply
  • 479 views

I am close to finishing a script that would find -- at the end of a graf -- some text in parenthesis and dump it at the top of the graf.

However, in the event there is text in parenthesis in the middle of the graf, I am having trouble with a Negative Lookahead.   I can't seem to have GREP leap past "(sample text in parenthesis)" in the middle of the graf.

Example Problem:

Here is the example text of what I want to accomplish.  Notice that it has (sample text in parenthesis) in the middle of the graf.  It also has text at  the end of the graf in parens that I want to capture. (xxxxx/xxxxx xxxxxx)

Example Solution:

xxxxx/xxxxx xxxxxx

Here is the example text of what I want to accomplish.  Notice that it has (sample text in parenthesis) in the middle of the graf.  It also has text at  the end of the graf in parens that I want to capture.

This topic has been closed for replies.
Correct answer Vamitul

if the closing parenthesis is the last thing in your paragraph you can use (\([^(]+?\))$

1 reply

Rocket95
Rocket95Author
Known Participant
March 19, 2015

Looking at a prior post, here's what my best attempt is so far:    (?<=\(.+\))

And this doesn't do anything.

Vamitul
VamitulCorrect answer
Legend
March 19, 2015

if the closing parenthesis is the last thing in your paragraph you can use (\([^(]+?\))$

Rocket95
Rocket95Author
Known Participant
March 19, 2015

That is the ticket!   :-)

Works great, thank you so much.