Regex To Get All Contents Within Curly Brackets

Let us say your string contains this data

{"1":"one", "2":"two"},{"3":"three", "4":"four"},{"5":"five", "6":"six"}

While regex can slow down performance, I decided to use it for this situation because I can do it using only a regex pattern. This regex will get all instances of a substring between two curly brackets { and }. In the example above, the result should be 3 entries since there are 3 sets of curly brackets. Please see the regular expression below.

\\{[^}]*\\}
Bookmark and Share

Found this post useful? Buy me a cup of coffee or help support the sponsors on the right.

Related Posts with Thumbnails

1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 5.00 out of 5)
Loading ... Loading ...

Leave a Reply