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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
([\d\w-.]+?\.(a[cdefgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrst]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|mil|museum|name|net|org|pro)(\b|\W(?<!&|=)(?!\.\s|\.{3}).*?))(\s|$)
Description
This will find URLs in plain text. With or without protocol. It matches against all toplevel domains to find the URL in the text.
Matches
http://www.website.com/index.html | www.website.com | website.com
Non-Matches
Works in all my tests. Does not capture protocol.
Author Rating: The rating for this expression. James Johnston
Source Modified, can't remember original 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: Abas Yobo
Name: Abas Yobo
Date: 4/9/2017 10:07:24 PM
Comment:
From : Abas Yobo, Country: Republic to Of Set Benin Location: Africa to the West, Dear One, the I Know This is on mail by COME To You color : as of a Suprise Since we 're Meet Or Have Not Had Previous of a Correspondence Please Bear With Me.i is on Realy Like To Have a good relationship with you, and i have a special reason why i decided to write you because of the urgency of my situation here. I got your contact informations through site and decided to contact you, hoping that by Almighty God grace, you will successfully assist me out from my situations after seven days of prayer and fasting over seeking for an overseas guardance. I am Abas Yobo (22 year's old) the only son of Mr.Adams Yobo a famous and wealthy cocoa and gold dealer base in Cotonou, the econimic capital of Republic of Benin. My father was poisoned to death by his business associates on one of their outings on a business trip. My mother died when i was a baby and since then, my father took me so special. Before he died, he secrectly called me on his bed side and told me that he has the sum of ($ 3,200, USD) .Three million, two hundred thousand united state dollars. Deposited in fixed / suspense account in one of the prime bank here in Cotonou, that he used my name as his only son the next of kin. I must not hesitate to confide in you for this simple and sincere business.I am seeking your urgent attention to help me transfer the sum into your account for an investment purposes, Such as real estates and stock markets business. And i want you to help me invest this money in your country and help me to locate a nice school to continue my education in your country.I am willing to offer you 20% of the total sum as compensation for your urgent assistance to me, immediately after the transfer of the fund into your account in your Country. I will be waiting for your urgent and favourable response. Sincerely yours, Abas Yobo abasyobo5@barid.com


Title: '(.*)@user_(\\S{8})([:| ])(.*)',2)
Name: Hamed
Date: 9/29/2016 12:44:19 AM
Comment:
what does this do?


Title: dont get adress with double dash
Name: azer kay
Date: 1/5/2016 6:53:41 PM
Comment:
on case like this one the regex dont work www.hotel‐4‐saisons.com in case it help i saw same problem for email and i post one that was not working : \b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\b and this one was ok with double dash : \b[_\S\d-]+@[_\S\d-]+\.[\S]{2,7}\b


Title: Doesn't work
Name: Anonymous
Date: 10/20/2011 5:05:14 AM
Comment:
Matches on everything!


Title: Alternate version
Name: Sect
Date: 5/29/2011 11:15:55 PM
Comment:
The following will work to capture "site.com/index.html." without including the trailing punctuation: \b(([\w-]+://?|www[.]|[\d\w-.]+?\.(a[cdefgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrst]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|mil|museum|name|net|org|pro)[/])[^\s()<>]*(\([\w\d]+\)|([^[:punct:]\s]|/)))


Title: This does not work
Name: JohnC
Date: 11/20/2008 2:14:35 AM
Comment:
This does not work at all. Very few of the regular expressions on this site do.


Title: James Johnstons url regex
Name: DC
Date: 6/24/2008 10:54:01 PM
Comment:
Works on almost all my tests except ftp://myname@host.dom/%2Fetc/motd prospero://host.dom//pros/name


Title: Ok... I got it.
Name: James Johnston
Date: 3/1/2005 11:03:43 PM
Comment:
I understand. Thanks. I appreciate the help. :) It includes all TLDs but how do I exclude certain matches? I've noticed that if a jpeg image is listed in the text it matches the .jp part of the extension and thinks it's a URL.


Title: Whuh? {1} DOES NOTHING, GET IT?
Name: Randal L. Schwartz
Date: 3/1/2005 9:37:50 PM
Comment:
You still have {1} there. It DOES NOTHING WASTE THREE CHARACTERS OF YOUR REGEX. Get it? {1} is useless. Pointless. Always. a matches 1 a a{1} matches 1 a Same exact thing Get it?


Title: Updated...
Name: James Johnston
Date: 3/1/2005 2:16:24 PM
Comment:
There... updated it. :) That should be better.


Title: Sorry... :]
Name: James Johnston
Date: 3/1/2005 2:00:50 PM
Comment:
Thanks for the suggestion about the PERL "URI::Find". I'm new to regexps and this worked in my tests. I didn't see a regexp on this site that did exactly what I wanted. I did notice the error with the second {1} after I'd already posted this. The last part of the regexp should be "coop){1}[:/]?.*?)(\s|$)" would also remove the need for the regexp to be followed by a newline or space. Is there a way to change my post?


Title: Bad
Name: Randal L. Schwartz
Date: 3/1/2005 7:00:05 AM
Comment:
First off, the {1} do absolutely nothing except take up three characters (twice!). Second, this is case sensitive. Third, you should probably look at the Perl "URI::Find" module to see how to do it right.


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