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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)?((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.[a-zA-Z]{2,4})(\:[0-9]+)?(/[^/][a-zA-Z0-9\.\,\?\'\\/\+&%\$#\=~_\-@]*)*$
Description
None of the other URL regex's seemed to work right for me, so i threw this together. works well with PHP's ereg().
Matches
http://www.sysrage.net | https://64.81.85.161/site/file.php?cow=moo's | ftp://user:[email protected]:123
Non-Matches
sysrage.net
Author Rating: Not yet rated. Brian Bothwell
Source IP validation is from another regexlib entry.
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
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: special character
Name: kruegge
Date: 8/3/2011 6:14:22 AM
Comment:
i have try it but i get no solution, how must the pattern be, so it also accept äöü in a domain and after tld? for example: http://www.domainwithü.com/aftertldwithä.html Can anybody help me? thanks kruegge


Title: in PHP doesn't work for me...
Name: nonhocapito
Date: 7/3/2009 12:35:01 PM
Comment:
unfortunately it gives me this: Warning: ereg() [function.ereg]: REG_ERANGE matching a url that starts with 'htp'


Title: Uri with single slash at end fails
Name: Jesse Gavin
Date: 10/4/2006 2:19:41 PM
Comment:
Uri with single slash at end fails. Example: http://www.nontalk.com/ does not validate


Title: :)
Name: small_R
Date: 8/29/2006 3:28:42 PM
Comment:
maybe it is not right place to ask but can someone can help me on Pattern that finds in teksts a link and show it like this *link*. so there are txt blablabla www.somthing.com blablabla and after processing its look like blablabla *link* blablabla and link has addressb : www.somthing.com


Title: :)
Name: small_R
Date: 8/29/2006 3:27:34 PM
Comment:
maybe it is not right place to ask but can someone can help me on Pattern that finds in teksts a link and show it like this *link*. so there are txt blablabla www.somthing.com blablabla and after processing its look like blablabla *link* blablabla and link has addressb : www.somthing.com


Title: Question
Name: Rob
Date: 1/30/2006 12:18:40 PM
Comment:
i'm getting an error "Invalid Range in charcter set" when i'm useing this in javascript. I know it has somthing to do with the part "\=~_" near the end. anyone knows how to modify it to work with Javascript?


Title: dunno
Name: edi
Date: 2/19/2005 6:53:00 AM
Comment:
try ftp://www.vodka-absolut.com/ to check it ;)


Title: fixed
Name: Brian Bothwell
Date: 10/18/2004 5:23:00 PM
Comment:
@ signs are now allowed in the query string. other characters should probably be allowed but i'm too lazy to lookup the RFC right now. ;)


Title: I think this expression is not correct
Name: SpiegS
Date: 7/11/2004 12:53:45 PM
Comment:
what about http://test@test@[email protected]


Title: Have the new one yet????
Name: Neal Richter
Date: 12/18/2003 7:44:44 PM
Comment:
Brian, Did you get the new version created yet??? Nice work on this!


Title: :)
Name: Brian Bothwell
Date: 12/17/2003 6:16:06 PM
Comment:
Forgot about that TLD. :) I suppose I should really change [a-zA-Z]{2,4} to a list of all valid TLDs. As for allowing localhost addresses, that's easy enough to add. I'll post a new one that allows localhost and all TLDs.


Title: :)
Name: MichaelRoth
Date: 12/17/2003 5:52:19 PM
Comment:
what about http://localhost/mysite ?? :)


Title: :)
Name: MichaelRoth
Date: 12/17/2003 5:48:50 PM
Comment:
try that with http://www.somesite.museum


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