Can someone share a regex that find all not double-slashed commented println in java code?
Example:
System.out.println("MATCH") /*this line match*/
// System.out.println("DOESN'T MATCH") /*this line doesn't match*/
(I’m using this regex into throw eclipse searching dialog)
Okay, as I already mentioned, regex is not the right tool, so if you end up using my suggestion, be sure to backup your source!
The following regex matches a single line that has
System.out.printin it,without//or/*before it (in that same line!).or simply:
which can then be replaced with:
to comment it.
Again: this will go wrong with multi line comments, and as Kobi mentioned, stuff like
/* // */ System.out.print...to name just two of the many cases this regex will trip over.Also consider the line:
you don’t want to end up with: