I am struggling to form the regex expression from the below String Array notes
.
I have tried to use few things below but I am not getting what I am expecting, like from notes[0]
I am only expecting 10.0
and higher
, Whereas it is printing all the String till the end higher than in-store
, I though \b...\b
will pick up the exact match but its not working here.
Any Pointers on this please.
notes = ["10.0% higher than in-store",
"5.0% lower than in-store",
"Same as in-store"]
String[][] twoDarray= new String[notes.length][2];
for (int index=0; index<notes.length;index++){
twoDarray[index]= notes[index].split("(\\%) | /\bhigher\b/ | /\blower\b/ | /\bsame\b/ | /\bas\b/");
}
System.out.println( twoDarray [0][0]); //10.0 (correct)
System.out.println( twoDarray [0][1]); //higher than in-store (expected: higher)
System.out.println( twoDarray [1][0]); //5.0 (correct)
System.out.println( twoDarray [1][1]); //lower than in-store (expected: lower)
System.out.println( twoDarray [2][0]); //Same as in-store (expected: Same)
System.out.println( twoDarray [2][1]); // no output? (expected: as)