How to match only extensionless URLs?

前端 未结 3 1926
旧巷少年郎
旧巷少年郎 2021-01-21 07:01

I want a regex expression which only match extensionless url. In otherwords if an extension is present in url then completely ignore it.

/(.+)/(.+) this wil

3条回答
  •  醉梦人生
    2021-01-21 07:42

    The following will only match strings which have at least two / (per your example regex), and don't have a . anywhere after the last /:

    /(.+)/([^\./]+)$
    

    I'd recommend http://www.regular-expressions.info/ if you want to learn more about regexs.

提交回复
热议问题