Quantcast
Channel: How to remove all text between the outer parentheses in a string? - Stack Overflow
Viewing all articles
Browse latest Browse all 8

Answer by alexamici for How to remove all text between the outer parentheses in a string?

$
0
0

re matches are eager so they try to match as much text as possible, for the simple test case you mention just let the regex run:

>>> re.sub(r'\(.*\)', '', 'stuff(remove(me))')'stuff'

Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>