-1

I need to remove all comments from a stript. Comments always start from '//'. My RegEx /\/\/.*/g does it but it removes substring if it inside quotes and I want avoid that behavior. Is there an ability to use RegEx for removing comments which are located only outside of quotes?

Michel_T.
  • 2,741
  • 5
  • 21
  • 31

1 Answers1

0

You can use negative lookahead (but I don't think this will match //foo "string")

(?!.*")\/\/.*
rusheb
  • 1,004
  • 9
  • 15