Below regex is working fine in most of the regex tools. However, its not working in the java code. Can anyone please advise?
String text="CHANGE FEE/ADD COLLECT DATA "+
"1.1 COLOR/RED TOMATO "+
"CF USD10.00 "+
" "+
"2.2 COLOR/DARK BLUE PLUM "+
"CF USD11.00 "+
" ";
String patterString = "([0-9]{1,3}\\.[0-9]{1,3})\\s.+\\s*CF\\s+[a-zA-Z]{1,5}([0-9]{1,10}.[0-9]{2})";
Pattern pattern = Pattern.compile(patterString);
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
System.out.println("found: " + matcher.group(1) +">>>"+ matcher.group(2));
}
actual output:
found: 1.1>>>11.00
expected output:
found: 1.1>>>10.00
found: 2.2>>>11.00