I am trying to check some strings. Here are the parameters.
Good Strings:
go
go2/api/hello
go/api45
Bad Strings:
/go (can't begin with a slash)
go//api (can't have a double slash)
go/api% (can't contain non number, letter or slash)
I've been trying to use RegExr.com but to no avail. I have been trying with this expression:
^[^\/](([0-9A-Za-z])+(\/)?)+
but it does not quite work.
You might try something like this (I hope whatever flavor you're using has lookahead!):
^(?!.*\/\/)[A-Za-z0-9][A-Za-z0-9\/]*$
Please see Regex 101 Demo for complete description and test strings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With