RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details URL Validator
Expression
/^(https?|ftp)(:\/\/)(([\w]{3,}\.[\w]+\.[\w]{2,6})|([\d]{3}\.[\d]{1,3}\.[\d]{3}\.[\d]{1,3}))(\:[0,9]+)*(\/?$|((\/[\w\W]+)+\.[\w]{3,4})?$)/
Description
This expression will test against most URLs and return whether they are valid URL's or not. It will allow some false positives in that it is only checking for the correct character count, but this could be enhanced by adjusting it to check for specific TLDs or file extensions.
Matches
http://www.website.com, http://subdomain.website.com, https://www.website.net/subfolder/subfolder/file.htm, http://www.website.org/subfolder/subfolder/file_weird%20Name$@#.pdf, https://209.165.5.487/about.html
Non-Matches
http://www.missingperiodcom, http:/misssingforwardslash.com, http://www.missingTLD., www.missingHTTP.com
Author Rating: Not yet rated. Harry
   Displaying page 1 of 1 pages; Items 1 to 1

Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials