Reputation: 11317
If I have this input string: {post:[matt]}
and I want to get the string where "matt" currently is, I'd use this:
Pattern pattern = Pattern.compile("^\\{(.+):[(.+)]\\}$")
Matcher matcher = pattern.matcher("{post:[matt]}");
if(matcher.matches()) {
// pattern matches input string
String str1 = matcher.group(2);
But if I had a string like this: {post:[matt,13-mar-2011,hello]}
how would I get the strings "matt", "13-mar-2011" and "hello" - when there may be a variable number of them? If it was just 3 it would be easy.
Upvotes: 0
Views: 762
Reputation: 159
You can try the find function, its supposed to find next match and next and next... I dont know if you will have to modify your pattern or not.
Upvotes: 2