I've come up with the following regular expression to match the valid url.
^(?:(ftp|http|https):\/\/)?(?:[a-zA-Z]+\.){0,1}(?:[a-zA-Z0-9][a-zA-Z0-9-]+){1}(?:\.[a-zA-Z]{2,6})?$
Which matches (ftp|http|https) optional, domain name without .com or anything but also I want to capture everything that come after .com.
The above regex validates http://stackoverflow.com
or localhost
or google.com
but not http://stackoverflow.com/questions/ask