For interactive parsing purposes, given an input string I need to extract the longest possible substring starting at index 0 and having only matched parentheses.
Example (LISP-like s-expressions)
Input string: (print "hello") (assign a (+ c d)) (assign e (+ f g)
Output substring: (print "hello") (assign a (+ c d))
I would like to make a simple Python function to achieve this.