Thursday, 8 August 2013

SED: I want to ignore patter "//" while reading file

SED: I want to ignore patter "//" while reading file

I have a script that removes // line comments from JavaScript source files.
cat $1 | sed -e "s|/\*\(\\\\\)\?\*/|/~\1~/|g" -e
"s|/\*[^*]*\*\+\([^/][^*]*\*\+\)*/||g" >> outfile
But removing // also removes it from strings like "http" + "//"+ "www" +
"xyz.com". How can I get this to ignore double slashes inside quoted
strings?

No comments:

Post a Comment