Search code examples
regexdirectory

Regex that matches directory path excluding filepath


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


Solution

  • Regex:

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

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

    Regex101