I have following string “Class (102) (401)” and “Class (401)” i want to find regex to find substring which always return me last bracket value in my case it is ‘(401) ‘
Following 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());
}
It is returning
–(
–)
–(
–)
You can use:
See it