0

Example- 1)(abc)xxx --> output-xxx

2)(abc)(xxx) --> output-xxx

3)((abc)xxx) ---> output-xxx

4)((abc) xxx + yyy)--> output-xxx+yyy

5)((abc)) ---> output-null

The Archetypal Paul
  • 41,321
  • 20
  • 104
  • 134
user470143
  • 49
  • 2
  • 7
  • 2
    You can't count balanced parentheses with a regexp. You'll need to use something else. – The Archetypal Paul Oct 11 '10 at 10:08
  • This isn't exactly a duplicate, but it has the same answer: http://stackoverflow.com/questions/3903965/regex-required-it-should-match-for-following-patterns – Greg Hewgill Oct 11 '10 at 10:09
  • True. http://www.texttoolkit.com/index.php?option=com_content&view=article&id=63:parsing-balanced-parenthesis-with-regular-expressions&catid=35:technology&Itemid=55 – Thilo Oct 11 '10 at 10:11

1 Answers1

0

This actually does what you ask for for all your examples, but I suspect is not what you wanted

[^\)]+\)[\(]*([^\)]*)

(tested here)

The Archetypal Paul
  • 41,321
  • 20
  • 104
  • 134