Submitted by Kiran on Tue, 02/03/2009 - 16:12
I have this regex -- /^([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/ which is not that effective.
Did any guy have a good tested regex for validating domain name.
»
- 1099 reads













Below is good tested regex for validating domain name
(([a-zA-Z0-9]|%[a-fA-F0-9]{2})(-([a-zA-Z0-9]|%[a-fA-F0-9]{2})+)?\.)+([a-zA-Z]{2,7}\.?)The following regex is very simple and i have used it for validating domain names
/^([a-z0-9][a-z0-9\-]*[a-z0-9]\.){2,}$/Thought of taking the discussion further you can try this regex
Post new comment