Reputation: 9011
I have a test string with pattern
{something1=any_character} any_character {something2=any_character}
I wanted to match the first bracketed sequence and in next iteration I wanted to match the next. So I am using Pattern
and Matcher
.
The regex I have is \{(\w)*something1.*(?!=).*(?!\})
but the problem is that it match the complete string rather then just the first one. I want to break the first search at first }
and then find next }
.
Upvotes: 0
Views: 83
Reputation: 36304
If you are using Pattern
and Matcher
, then only capture groups like this :
(\\{\\w+=\\w+\\})
and use a while()
loop with matcher.find()
Upvotes: 1