Reputation: 303
I am using a regular expression for validation web url. that is not validating more than one dots(.) like www.gmail.....com, other than this it is working fine.can any body update my regular expression-
^[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$
Upvotes: 0
Views: 976
Reputation: 11912
UPDATE. Note this is not foolproof by any means.
^([a-zA-Z0-9\-]+\.)+(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$
The +
tells the regex to match one or more times
Upvotes: 2
Reputation: 186108
For Perl-compatible regex syntax, you can do this:
^([a-zA-Z0-9-]|\.(?!\.))+\.(com|...
Also, this is very US-centric. My company's domain ends in .com.au
.
Upvotes: 0