I'm writing a Javascript minifier in python, and I'm trying to remove comments by using a regular expression
\s\/\/[^\n]*\n
The javascript that is giving me unexpected results from the regex is
/* deliberately different */
// test line 1
// test line 2
var test_http = "http://test.com";
I'm using the great regex testing resource at Regex101 and it's showing that // test line 2
is not matched, and I don't understand why.
NOTE: I am deliberately looking for white-space (includes newlines) before a comment in order NOT to match declarations such as the test_http
variable.
Can anyone shed some light on this for me please?
答案 0 :(得分:0)