regex - how to get the array of strings that are inside curly braces in the source string in java -
I want a string of string with its contents: {is}, {string}, {contains}, {substrings} {braces}
"{is} a sample {string} in which {corporat} {substrings} are inside I curly (braces)"
From it, it is taking all the characters that are in the middle of the first open curly braces and the last closing Kurli braces.
some time The libraries and functionality I spent with will need to provide this example ...
string exp = "\\ {(. *?) \\}"; string value = "this { A} flat {string} that {keeps} {curly} {braces} inside {substrings}; Pattern Pattern = Pattern.compile (exp); Matcher matcher = pattern.matcher (value); List & lt; string & gt; ; Matches = new arreelist & lt; string & gt; (5); while (matcher.find ()) {string group = matcher.group (); matches.add (group);} string [] group = matches.to Array (new st Ing [max. Size ()]); Println (Arrays.toString (group));
Which output
[{}}, {string}, {included}, {substrings}, {braces}]
/ Ex>
Comments
Post a Comment