I am trying to build HTML parser that replaces for example alert("hi there123");
with "".
So
alert(123); var hello = 0;
console.log(hello);
Will become:
var hello = 0;
console.log(hello);
Someone suggested using regex, so I dove into that.
Now this is what I found online:
something(.*?)something
will grab the text between the words "something" and "something", but when I try to do with with the word "alert(" <-- notice the ( , it doesn't work.
P.S. What I am trying to do, is first remove the text between the alert() and then remove alert(); like so: string.replace("alert();", "");
And does regex loop over every occurrence?
If anyone has a better solution, be sure to inform me.
Any help would be appreciated.