Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16862

terminate regexp search when pattern condition was first met

$
0
0

I'm trying to run sql script in python during my data processing, the script file I used contains annotations surrounded by /**/ and I want to delete those annotations. Since I may have multiline annotations and multi annotation chunks in a single file, I'm using

re.sub('/\*((?!/\*).)*/\*','',cmd,flags=re.DOTALL)

but the above code will only replace those multiline annotations and ignore single line annotaions. Now I'm confused how to make it work


Viewing all articles
Browse latest Browse all 16862

Trending Articles



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