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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Find URL in text
Expression
/((https?|ftp)\:\/\/)?([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?(([a-z0-9-.]*)\.([a-z]{2,6}))|(([0-9]{1,3}\.){3}[0-9]{1,3})(\:[0-9]{2,5})?(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:@&%=+\/\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?/i
Description
This could be most complete and readable URL-finder regex. I built it from several good examples. Works with PHP preg_match_all(). Finds whatever string that resembles a URL with scheme://, user:password, subdomains.domain (with up to 6 chars top-domain) or IP address xxx.xxx.xxx.xxx, :port, /file/path/, ?request, and #anchor
Matches
google.com
Non-Matches
file://hello.txt
Author Rating: The rating for this expression. Marco Alvarado
Source
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: it is also matching this..http://www.google is not correct in any format....
Name: Tirumal
Date: 6/3/2016 10:40:31 AM
Comment:
it is working with all other but it is allowing with out any domain name like .com or .co.in or.in


Title: Excellent!
Name: thanos
Date: 1/29/2012 11:45:06 AM
Comment:
you sir have saved my day! Cheers!!


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