Question

In Python, how to return substring between parenthesis in a string?


Annonce
Ad

Answer

The following returns the text between the first pair of parentheses:
s="example (the)"
text = s[ s.find( '(' )+1 : s.find( ')' ) ]
# text = 'the'


[source]
# ID Query