the following block of code is producing a "No match found" error, despite online resources computing that the regular expression is a match to the String from Scanner "scnr." If anyone can give a short code fix with minimal changes, that would be great.
String p = "([0-9]*),([0-9]*),(r|b)";
System.out.println("regex: " + p);
Pattern pattern = Pattern.compile(p);
Matcher matcher;
String testString = scnr.next();
System.out.println("test string: " + testString);
matcher = pattern.matcher(testString);
matcher.matches();
System.out.println(matcher.group(1));
System.out.println(matcher.group(2));
System.out.println(matcher.group(3));
Output:
regex: ([0-9]*),([0-9]*),(r|b)
test string: (1,65,b)
Exception in thread "main" java.lang.IllegalStateException: No match found