Skip to content
Advertisement

How to do multiline search and replace with a script?

I’m trying to replace every multiline import inside a Python source file.. So, the source goes like

JavaScript

and I’d like to get something like

JavaScript

I tried to use sed but it looks like it doesn’t support non-greedy matching of the closing parenthesis, so it “eats” the second import.. 🙁
Any hint? Is this impossible with sed? Should I try with another tool?

Advertisement

Answer

Ummm… what’s wrong with Python?

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement