I have the following URIs:
/controller/method/arg1/arg2
-
/controller/method/arg1/arg2/
<- tailing slash -
/controller/method/arg1/arg2?param=1¶m=2
<- tailing query string
I need a regular expression to extract always /controller/method/arg1/arg2
, while keeping in mind that it can end with /
, ?
or ?
+ some characters.
This:
^\/.*\??
is not working for me, as it is taking the chars before ?
.
I don't care if the resulting string includes /
or ?
at the end, I can trim it.