Regular Expressions 101

Remove double-slash comments

Open Workspace
  • Python
  • Substitution
0

Regular Expression

r"
("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|(?:[^/\n"']|/[^/*\n"'])+|\n)|(/\* (?:[^*]|\*[^/])*\*/)|(?://(.*)$)$
"
gm

Description

This regex removes double-slash comments while avoiding anything between 'quotes' or "double quotes".

Submitted by jlacroix