I have the line "Class (102) (401)" and "Class (401)". I want to find a regex to find a substring that always returns me the last value of the bracket, in my case it is "(401)"
Below is my code
Pattern MY_PATTERN = Pattern.compile(".*(\\(\\d+\\))");
Matcher mat = MY_PATTERN.matcher("Class (102) (401)");
while (mat.find()){
System.out.println(mat.group());
}
He returns
- (-) - (-)
source
share