I would like to split these strings:
into following list of segments:
For the other cases, splitting using / will not get the result that I wanted. In which case, the last string element of 2. and 3. will be {c}{?d} and c{?d}.
What is the best approach to achieve all 1,2,3 at the same time?
Thanks.
try to solve the problem with a regex. This might be a script to start with:
String regex = "(/)|(?=\\{)";
String s = "/a/b/{c}{?d}";
String[] split = s.split(regex);
you will get empty elements in the split array with this regex, but all other elements are splitted correctly