问题
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