java regex help
From: Rick Venter (rick_venter_at_yahoo.com)
Date: 10/27/03
- Next message: VisionSet: "Re: java regex help"
- Previous message: Matt Wharton: "Re: simple Math question"
- Next in thread: VisionSet: "Re: java regex help"
- Reply: VisionSet: "Re: java regex help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Oct 2003 11:43:27 -0800
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());
}
- Next message: VisionSet: "Re: java regex help"
- Previous message: Matt Wharton: "Re: simple Math question"
- Next in thread: VisionSet: "Re: java regex help"
- Reply: VisionSet: "Re: java regex help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|