开发者

Regular expression for removing the page part of a url

开发者 https://www.devze.com 2023-02-04 08:47 出处:网络
Can someone show me a regex that will remove the page part from a string. My strings are either /section/

Can someone show me a regex that will remove the page part from a string.

My strings are either

/section/ 
/section/page.html
/section/subsection/page.html

I need a regexp that would return

/section/
/section/
/section/su开发者_运维技巧bsection/

You can assume the file ext is always .html and the strings are relative (no http://host:port)

Thanks!


I think you're looking for:

/(.*/)+
0

精彩评论

暂无评论...
验证码 换一张
取 消