I'm trying to create a pattern for negative look behind regEx to not to match certain lines of code in my java file.
I could match the phrase with this "(?<=//).*getMessage.*
"
Above expression matches Line #1 in below code,
// Systme.out.println (obj1.getMessage()); //line1
/* Systme.out.println (obj.getMessage());*/ //line2
/* public void test() { //line3
Systme.out.println (obj2.getMessage()); //line4
} //line5
*/
public void test() {
Systme.out.println (obj5.getMessage()); //line 6
}
But, when i tried negate this using "(?<!//).*getMessage.*
", It still matches all the Line #1,#2 and #4 as well.
Actually my requirement is to match the getMessage
call at line #6 and ignore other places where getMessage
is called inside comments.
It would be great if someone can assist me in finding the right expression.
PS: I can't access java files... I just have to pass the RegEx to a form and select all the java files checkbox.