REGULAR EXPRESSION: two short instead of one long

  • Thread starter Thread starter teo
  • Start date Start date
T

teo

Hallo,

I have a phrase
with a couple of sentences inside parentheses
like this:

abtrcd (efug) hilam (nopeq) rsmtvz


I need TWO matches like:
(efug)
(nopeq)

unfortunately I get ONE long match like:
(efug) hilam (nopeq)

-----------------------

I'm currently using:
\(.*\)

Any help?
 
Try \([^)]*\)




I have a phrase
with a couple of sentences inside parentheses
like this:
abtrcd (efug) hilam (nopeq) rsmtvz
I need TWO matches like:
(efug)
(nopeq)
unfortunately I get ONE long match like:
(efug) hilam (nopeq)

I'm currently using:
\(.*\)
Any help?

If you don't mind me jumping in here, that appears to be able to find
the first occurance, but how would you return the second? Or third or
fourth, etc?
 
Try \([^)]*\)

Great!
I played a little with it and it really seems to work.

Another little case (if I may ask it it)
if I have infinitely variable nested parentheses like:

abtrcd (efughi (noiop (eyq) iouer) rsmtvz) vbfrsde

and I'd like to match all of them like:

(efughi (noiop (eyq) ioer) rsmtvz)
(noiop (eyq) ioer)
(eyq)

is there a way?
Your
\([^)]*\)
obviously doesn't work, it matches only this:
(efughi (noiop (eyq)
 
Back
Top