I would like to scan txt file and look for if statement (an if not a SOMETHINGifSOMETHING).
I was thinking about something like that
[\\W|\\s]*if[\\s*|\\(]
but it does not work.
How can I make this "if" regex?
class Test {
public static void main(String[] args) {
// if (x > 10) a = b;
int pif = 2; // if
int ifa = 3;
int ifff;
int kif;
int cif;
/*
if
*/
int a = 0, b = 0, c;
if (a > b) c = 1; // wariant jest subwariantem
if(a > b) c = 1;if (a<b) c=1; if(a==b) c= 7;
if (a>b) c =1; else if (a==b) c=2;
if (a>b) c =1; else {if(a==b) c=2;}
if
(a<b) c = 7;
}
}
You can try this:
it will not know which are commented out, but it will find all the "if"s and not capture all the somethingIfSomethings.