I am new to regular expressions and powershell scripting.
I have a lot of javascript files in my directory. Most of them contain the statement "window.open(...)" (possibly a hundred times).
What I'd like to do is to replace all lines containing one of the following:
window.open('...', ...)window.open('...')window.open("...", ...)window.open("...")
With the following, respectively:
window.open(encodeURI('...'), ...)window.open(encodeURI('...'))window.open(encodeURI("..."), ...)window.open(encodeURI("..."))
In short, I would like to insert the function encodeURI(...) in front of every first argument in the function call window.open(...), if it exists (no need to do anything with window.open() which has no arguments at all).
I know how to find all the javascript files in a directory and process every file on its own for each of these files. However, I am having some trouble performing what I described. I thought with regular expressions, any ideas are appreciated.
Thank you,
Regards.


