The title is not clear, so I write some sample to explain.
There is a string, which contains many nested {}
s:
/users/{<\w{2,4}\d{3}>id}
You can see I use {}
as a placeholder for path variables, and it can have regex inside and which can also have {}
.
How to write a regex with java to parse the path pattern, find the {}
parts which don't have outer {}
. For this example, it should be {<\w{2,4}\d{3}>id}
.
Thanks~
UPDATE
The given example is too simple, it can be:
/users/{<\w{2,4}\d{3}>id}/{action}/{<\w{2,4}\d{3}>targetId}
The result should be:
{<\w{2,4}\d{3}>id}
{action}
{<\w{2,4}\d{3}>targetId}
So \\{.*\\}
doesn't work.