Tuesday, 15 July 2014

How can I match nested brackets using regex? -



How can I match nested brackets using regex? -

as title says, here illustration input:

(outer (center (inner) (inner) center) ouer) (outer (inner) ouer) (outer ouer)

of course, matched strings processed recursion.

i want first recursion match:

[ (outer (center (inner) (inner) center) ouer), (outer (inner) ouer), (outer ouer)]

and after processes needless say...

you can utilize regex

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

but match multiple () in single match!but illustration guess there won't problem

regex nested

No comments:

Post a Comment