\s
matches any whitespace character, and a newline character is a whitespace character, so it gets matched by it (and then the whole next line is matched by ([^\n]*)
).
Optionally match a plain space instead (and remove the \s
from the end of prevent\s?eval\s
in the first alternation).
You can also use .*
instead of [^\n]*
, you probably wouldn't want to match a linefeed character anyway:
^\/\/\s(prevent\s?eval|eval\s?prevent) ?(.*)$
It sounds likely that you don't want any of the \s
s to match newlines in which case, replace them all with plain spaces:
^\/\/ (prevent ?eval|eval ?prevent) ?(.*)$