This should be simple but I can't seem to get it exactly right. I need to extract the uri stem/path only from a uri where it could end with a '/' or not and have a query string or not.
So use cases are as follows
- /shopping/cart ----> /shopping/cart
- /shopping/cart/ ----> /shopping/cart
- /shopping/cart/?param1=val1¶m2=val2 ----> /shopping/cart
- /shopping/cart?param1=val1¶m2=val2 ----> /shopping/cart
So far I have tried ^(\\/.\\*)\\/ and ^(\\/.\\*)\\/?.
I also would prefer to stay away from double groupings if at all possible
使用正向超前断言( 更多信息 )来查找问号:
^(/.*)(?=\?)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.