Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Python

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

Description

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

Submitted by jlacroix - 10 years ago