1

We've tried many solutions about how to remove JS comment by regular expression, but there's one case which always breaks my JS:

const a = "/*";
const b = "*/";

We commonly use Accept: "application/json, text/plain, */*" on our script so it always break our JS.

I'm looking for a regex that can ignore the searching within

"", '', ``

string in JS or any other solution.

Thanks.

Stanley Cheung
  • 929
  • 7
  • 22

1 Answers1

0

You can use a negative lookahead after your final / to make sure it's not followed by a * like so:

\/\*.*\/(?!\*)

Example https://regexr.com/4m025

DrRoach
  • 1,320
  • 9
  • 16