java - How to split string into parts defined by brackets -
it seems simple, can't find solution. need values string {value1}{value2}.....{valuen}
. i've tried create pattern as: (\\{(.*)\\})*
or (\\{(.*?)\\})*
. in both cases 1 value: between marginal brackets or last value. need replace (.*)
meaning anything except }{
.
in advance help.
i go for:
string str = "{value1}{value2}...{valuen}"; str = str.substring(1,str.length-2); // crop first , last bracket string[] results = str.split("\\}\\{"); // array of results
i don't matching stuff regex when can go less confusing. next dev who's gonna work on same code.
Comments
Post a Comment