I would like someone to help me to rectify my regular expression to split this string:
{constraint.null.invalid}{0,1,2}
Basically, I want anything inside { and }, so my output must be:
constraint.null.invalid0,1,2.
My regular expression, which I've tried closely is:
\{([\S]+)\}
But the value I get is:
constraint.null.invalid}{0,1,2
What am I missing?
Sample code:
public static void main(String[] args) {
Pattern pattern = Pattern.compile("\\{([\\S]+)\\}", Pattern.MULTILINE);
String test = "{constraint.null.invalid}{0,1,2}";
Matcher matcher = pattern.matcher(test);
while (matcher.find()) {
System.out.println(matcher.group(1));
}
}
Thanks
PS: The string can contain values bounded by 1 or more { and }.