Title |
Test
Find
Pattern Title
|
Expression |
^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*$ |
Description |
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 |
http://www.blah.com/~joe | ftp://ftp.blah.co.uk:2828/blah%20blah.gif | https://blah.gov/blah-blah.as |
Non-Matches |
www.blah.com | http://www.blah"blah.com/I have spaces! | ftp://blah_underscore/[nope] |
Author |
Rating:
Brandon Luhring
|
Source |
Modified from other RegExp's on ASPSmith. |
Your Rating |
|
Title: Error in 1st domain
Name: Joe
Date: 2/3/2004 1:41:00 PM
Comment:
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
Comment:
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
Comment:
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
Comment:
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\-\._\?\,\'/\\\+&%\$#\=~])*$
Title: A bit out of date.
Name: Paul Houle
Date: 6/11/2003 1:14:03 PM
Comment:
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.
Title: RETYYRYS?GFS?GS?
Name: ?FG???
Date: 4/7/2003 11:22:45 AM
Comment:
?F?
Title: thlktuli
Name: ytouyyto"SDF"
Date: 4/7/2003 11:21:13 AM
Comment:
RTYUYTJCHGJG"SDFG"