R
Rick Venter
I am trying to create a regular expression for matching a pattern with
a string enclosed in curly braces { } and not able to do that using
java.
For ex: if the String is
foo {bar} alpha {baz}:{bat} gamma
I need the strings:
{bar}
{baz}
{bat}
after the pattern matching
How do I do that ? Following is the code snippet and it is not
printing out anything. I think my regular expression pattern might be
wrong.
Can anyone help ?
protected static final String PARAMETER_REGEX =
"\\{\\[\\^\\{\\}\\]+\\}";
String originalString = "foo {bar} alpha {baz}:{bat} gamma";
Pattern p = Pattern.compile(PARAMETER_REGEX);
Matcher m = p.matcher(originalString);
while(m.find()) {
System.out.println(matcher.group());
}
a string enclosed in curly braces { } and not able to do that using
java.
For ex: if the String is
foo {bar} alpha {baz}:{bat} gamma
I need the strings:
{bar}
{baz}
{bat}
after the pattern matching
How do I do that ? Following is the code snippet and it is not
printing out anything. I think my regular expression pattern might be
wrong.
Can anyone help ?
protected static final String PARAMETER_REGEX =
"\\{\\[\\^\\{\\}\\]+\\}";
String originalString = "foo {bar} alpha {baz}:{bat} gamma";
Pattern p = Pattern.compile(PARAMETER_REGEX);
Matcher m = p.matcher(originalString);
while(m.find()) {
System.out.println(matcher.group());
}