Reputation: 2007
My url will be like localhost:5557
. And I will not allow http://
or https://
or ftp://
in my url.
Also I tried
^(?:!(ftp|http|https):\/\/)?([a-zA-Z0-9]+\.)?[a-zA-Z0-9][a-zA-Z0-9-]+\.[a-zA-Z]{2,6}?$
But I am getting false
when adding the port number
.
Any suggestions please !
Upvotes: 1
Views: 161
Reputation: 174826
Negative lookahead must be like (?!..)
not (?:!...)
^(?!(ftp|https?):\/\/)([a-zA-Z0-9]+\.)?[a-zA-Z0-9][a-zA-Z0-9-]+\.[a-zA-Z]{2,6}(?::\d{4})?$
Upvotes: 1