I'm not sure exactly what you're asking and your regex isn't much help in providing additional information.
However, if brackets can't nest and you don't want to handle escaped brackets then the regex is pretty straight-forward.
Note: even your most recent regex (probably should have just edited your post instead of responding to yourself: \\S+\\s*[=]\\s*[{].*[},]
Is doing some things it doesn't need to that will certainly mess you up. The over-use of [] style character classes is probably confusing you. Your last [},] is really saying "character matching '}' or ','" which is I'm pretty sure not what you mean.
Regex seems to be everyone's favorite whipping boy but I think it's appropriate here.
Pattern p = Pattern.compile( "\\s*([^={}]+)\\s*=\\s*{([^}]+)},?" );
Matcher m = p.matcher( someString );
while( m.find() ) {
System.out.println( "name:" + m.group(1) + " value:" + m.group(2) );
}
The regex breaks down as:
- Any preceding whitespace.
- First capture group is a non-zero length string containing only characters that are NOT '=', '{', or '}'
- Any intermediate whitespace.
- '='
- Any intermediate whitespace.
- '{'
- Second capture group is a non-zero length string containing only characters that are not the closing '}'
- '}'
- Optional ','
This regex should perform more efficiently than the .* versions because it is easier for it to figure out where to stop. I also think it is clearer but I speak regex conversationally. :)