开发者

Regex To Search for Nested Brackets [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

Can regular exp开发者_开发问答ressions be used to match nested patterns?

How do I use regular expressions to search for a pair of opening and closing brackets with arbitrary number of nested brackets inside it e.g.

(...(...(...(...) ...) ...) ...)

Each opening bracket must be matched by a closing bracket. And the number of nested opening-closing pair is arbitrary. Other alphanumeric characters may appear inside the brackets.


If you really want to use RegEx to do it(i'm not sure it's the good way), you can loop until this regex \([^\(\)]*\) returns nothing, and for each times you get something you have to remove the result in the initial and loop again...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜