You say that you want the first path component, without any slashes, to be in the first variable, and everything after it, including slashes, in the second variable.
Let's see how your current regex looks, at regex101:
When we give it the string to match:
/test_t/company/Default/icon_category/Hotel.png the first group is
test_t/company/Default/icon_category and the second group is
The reason for this is that the first group is followed by a literal character
/, and the
.* match quantifier is greedy, meaning in this case it will keep going until the last
/ in the string after the capture group. This is why you see nearly the entire path in the first variable.
To fix that, you need to make the quantifier lazy, so that it stops matching at the first occurrence of whatever comes after it in the regex. To accomplish this we change
Now on regex101 you can see the first capture group is
test_t as you wanted, but the second capture group does not include the forward slash. This is because the literal
/ is between the two capture groups, thus it won't be included in either of them.
Because you want it to be included in the second variable, we will move it inside the second capture group, so
(/. Here is how the third iteration looks on regex101.
This results in the first variable being
test_t and the second being
If you want to make further changes, you can try them out on regex101 yourself to see the results instantly. This way you can learn how everything works before you make any changes to your live configuration.