Creating Regex for url path

Socks93

Active member
Joined
Oct 22, 2021
Messages
29
Programming Experience
Beginner
Hi, im very new to regex and have been trying to create an expression which creates validation for a path. Below are the rules I would like to include

- MUST begin and end with forward slash e.g /example/
-path name must be between 1-63 characters
- no upper case characters allowed
-no spaces
-can only contain the following symbols "-", ".", "_", "~"

This is what I currently have ^((?/)[a-z0-9]{1,63}/)$

Can someone please tell me how to include all rules above?

Thankyou!
 
Last edited:
Sounds like a Regex question rather than C# question....
 
Why does your character range include the numbers 0-9 when your specification says that only lowercase characters are allowed along with those special characters?
 
Anyway the \p{Ll} character class should let you match lowercase characters.
 
Back
Top Bottom