TallChuck TallChuck - 7 months ago 48
Python Question

Python Regex that will work for any type of bracket

Is there a way to take a regular expression, such as


and make it correctly identify pairs of any type of bracket, like


without making incorrect matches, like

I'm specifically working with Python, but it should work similarly in any language.


No. Regular languages can't handle nesting correctly. You'll need a proper parser for that.