Well, as I mentioned, regex isn't the right tool, so if you end up using my suggestion, be sure to back up your source!
The following regular expression matches the same line with System.out.print in it, without // or /* in front of it (on the same line!).
(?m)^((?!//|/\*).)*System\.out\.print.*
or simply:
(?m)^[ \t]*System\.out\.print.*
which can then be replaced by:
//$0
to comment on this.
Again: this will not be the case with multi-line comments, and as Kobe said, for example, as /* // */ System.out.print... to name only two of many cases, this regular expression will fire.
Also consider the line:
System.out.println("...");
you do not want to end up with:
//System.out.println("..."); /* comments */
source share