Regular Expressions 101

Community Patterns

Community Library Entry

-1

Regular Expression
Python

r"
^(?:(((([^"\n]|(['\\]"))*?)((?<=[^\'])")){2})*[^"\n]*)(\/\/.*?)$
"
mg

Description

This regex matches java line end comments started with "//" and ignores such ones that are within String literals. (NO SUFFICIENT TESTING WAS DONE TO GUARANTEE 100% SAFETY)

Submitted by Janis Schöck - 9 years ago