-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,623
  • 5
  • 20
  • 31

1 Answers1

0

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

(?!.*")\/\/.*
rusheb
  • 642
  • 7
  • 9