Regex that matches directory path excluding filepath

浪子不回头ぞ 提交于 2019-12-23 21:39:34

问题


I'm looking for a regex pattern that I need for IIS. Basically I want it to match any directory path but reject file paths. I've searched all over with little luck.

Example: Match: /directory/content/css/ Match: /directory/content/css Reject: /directory/content/css/main.css Reject: /directory/content/css/main.anything

!--Due to feedback I've made some changes (Apologies this is my first time on the forum)--!

So far I've put together this pattern: ^(\/.*)(.*)*[^.*]$ It appears to start out ok accepting anything starting with / but it still accepts extensions.

Thanks


回答1:


Regex:

(?:\..*(?!\/))+

This regex will match if you got a file path..

Regex101



来源:https://stackoverflow.com/questions/20056104/regex-that-matches-directory-path-excluding-filepath

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!