I'm in need of an expression for finding a name in a dynamic path string.
Basically I need to find a string before last >
character and it must be inside these >
characters.
Lets say I have this string:
"Category 1 > Category 1.1 > Category 1.1.1"
With this expression \>(.*)\>
it works, and I get the desired string which is "Category 1.1"
.
The problem is if this string doesn't have a >
at the beggining.
E.g.
"Category 1.1 > Category 1.1.1"
I tried something like this \>?(?=>)?\>?(.*)\>
and this works but only for this case. When I test it with "Category 1 > Category 1.1 > Category 1.1.1"
, it returns Category 1 > Category 1.1 >
which is wrong.