- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find Pattern Title
Modified URL RegExp that requires (http, https, ftp)://, A nice domain, and a decent file/folder string. Allows : after domain name, and these characters in the file/folder sring (letter, numbers, - . _ ? , ' / \ + & % $ # = ~). Blocks all other special characters-good for protecting against user input!
Matches | |
Non-Matches | http://www.blah" have spaces! | ftp://blah_underscore/[nope]
Author Rating: Not yet rated. Brandon Luhring
Source Modified from other RegExp's on ASPSmith.
Your Rating
Bad Good

Enter New Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Error in 1st domain
Name: Joe
Date: 2/3/2004 1:41:00 PM
Good chunk, but it matches with http://www.regexplib.verylongdomainname/index.php, and I've got no idea how to fix it... Anyone?

Title: prudence
Name: isaac sinyinza
Date: 1/8/2004 6:37:38 AM
i am very much interstred in tyring to know more about this site

Title: some improvements to work in perl
Name: tino
Date: 9/6/2003 7:20:56 PM
this will catch and IP addess as a hostname along with up to 5 character TLD's ((http|https|ftp)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z0-9]{2,5}(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?\,\'\/\\\+&%\$#\=~])*) and here is the perl code to look through a block of text and replace all urls with links $inputtext =~ s/((http|https|ftp)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z0-9]{2,5}(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?\,\'\/\\\+&%\$#\=~])*)/\<a href=\"$1\"\>$1\<\/a\>/gs; have fun

Title: Localhost Urls
Name: Andreas Blum
Date: 6/26/2003 9:34:20 AM
I found this addition usefull, as it also allows localhost urls: ^(http|https|ftp)\://(([a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*))|localhost)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&amp;%\$#\=~])*$

Title: A bit out of date.
Name: Paul Houle
Date: 6/11/2003 1:14:03 PM
A good regex, but it's a little out of date. Now there are domain names with other than two or three characters in the top level domain, such as .info/.aero/.coop You could include a list of these domains or you could just be permissive and allow the top level domain to be any combination of more than one letter.

Name: ?FG???
Date: 4/7/2003 11:22:45 AM

Title: thlktuli
Name: ytouyyto"SDF"
Date: 4/7/2003 11:21:13 AM

Copyright © 2001-2018, | ASP.NET Tutorials