String errMsg = "{1} and {2} values can't be same!!!";
Pattern pattern = Pattern.compile("\\{[1-9]+\\}");
Matcher matcher = pattern.matcher(errMsg);
while(matcher.find()){
System.out.println(matcher.group());
}
Output:
{1}
{2}
Pattern pattern = Pattern.compile("\\{[1-9]+\\}");
Matcher matcher = pattern.matcher(errMsg);
while(matcher.find()){
System.out.println(matcher.group());
}
Output:
{1}
{2}