Regular Expressions 101

remove C-style comments (string aware)

Open Workspace
  • JavaScript
  • Substitution
2

Regular Expression

/
(".*?"|'.*?')|(\/\/.*|\/\*[\S\s]*?\*\/)
/
gm

Description

I made this a while ago, but the code works. Please use a real parser. Works with double quotes and single quotes.

Submitted by Twineee(.rf.gd)