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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
((mailto\:|(news|(ht|f)tp(s?))\://){1}\S+)
Description
Regular Expression matches any internet URLs. Used with the replace method it comes in very handy.
Matches
http://www.aspemporium.com | mailto:dominionx@hotmail.com | ftp://ftp.test.com
Non-Matches
www.aspemporium.com | dominionx@hotmail.com | bloggs
Author Rating: Not yet rated. Justin Saunders
Source http://www.aspemporium.com/aspEmporium/examples/regexp_LinkURLs.asp
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: Extra quantifier
Name: Solly
Date: 6/17/2016 12:25:04 PM
Comment:
Why is there an extra "{1}" in the regex?


Title: How to block the URL/links in the user's entry
Name: Khushi
Date: 3/30/2012 2:24:33 PM
Comment:
I want to restrict users so that they can not enter any url or hyperlinks Please Suggest.


Title: Doesn't match international urls
Name: Mark
Date: 1/12/2012 4:48:58 AM
Comment:
I tried it with www.abc.co.il (a company in israel) and it didn't match.


Title: Bug!
Name: Brent Boyer
Date: 1/7/2010 5:39:12 PM
Comment:
I think that the expression, as originally provided, is subject to the following bug: that final \S+ matches strings that end with, say punctuation. To see the issue, suppose that we are searching for URLs in the source text "blah blah blah (http://www.ibm.com) blah blah blah". Then that expression will report "http://www.ibm.com)" as the URL, which is wrong, as it includes the final parentheses. One possible fix is to use negative look behind to restrict matches from ending in punctuation. The current URL regex that I am using (with Java's regex engine) is "(?:(?:mailto\\:|(?:news|(?:ht|f)tp(?:s?))\\://){1}\\S+)" + "(?<!\\p{Punct})" That seems to do the trick for me for MY PARTICULAR URLs. WARNING: this is not a general cure all, since there are valid URLs which end in punctuation. For instance, a final underscore ('_') char should be fine. Perhaps a better more general solution would be to replace "(?<!\\p{Punct})" with something less broad, like "(?<![^,^\\)^\\]^\\}])" Please post back with any feedback.


Title: Bug!
Name: Brent Boyer
Date: 1/7/2010 3:26:50 PM
Comment:
I think that the expression, as originally provided, is subject to the following bug: that final \S+ matches strings that end with, say punctuation. To see the issue, suppose that we are searching for URLs in the source text "blah blah blah (http://www.ibm.com) blah blah blah". Then that expression will report "http://www.ibm.com)" as the URL, which is wrong, as it includes the final parentheses. One possible fix is to use negative look behind to restrict matches from ending in punctuation. The current URL regex that I am using (with Java's regex engine) is "(?:(?:mailto\\:|(?:news|(?:ht|f)tp(?:s?))\\://){1}\\S+)" + "(?<!\\p{Punct})" That seems to do the trick for me for MY PARTICULAR URLs. WARNING: this is not a general cure all, since there are valid URLs which end in punctuation. For instance, a final underscore ('_') char should be fine. Perhaps a better more general solution would be to replace "(?<!\\p{Punct})" with something less broad, like "(?<![^,^\\)^\\]^\\}])" Please post back with any feedback.


Title: Bug!
Name: Brent Boyer
Date: 1/7/2010 3:13:20 PM
Comment:
I think that the expression, as originally provided, is subject to the following bug: that final \S+ matches strings that end with, say punctuation. To see the issue, suppose that we are searching for URLs in the source text "blah blah blah (http://www.ibm.com) blah blah blah". Then that expression will report "http://www.ibm.com)" as the URL, which is wrong, as it includes the final parentheses. One possible fix is to use negative look behind to restrict matches from ending in punctuation. The current URL regex that I am using (with Java's regex engine) is "(?:(?:mailto\\:|(?:news|(?:ht|f)tp(?:s?))\\://){1}\\S+)" + "(?<!\\p{Punct})" That seems to do the trick for me for MY PARTICULAR URLs. WARNING: this is not a general cure all, since there are valid URLs which end in punctuation. For instance, a final underscore ('_') char should be fine. Perhaps a better more general solution would be to replace "(?<!\\p{Punct})" with something less broad, like "(?<![^,^\\)^\\]^\\}])" Please post back with any feedback.


Title: Bug!
Name: Brent Boyer
Date: 1/7/2010 3:06:46 PM
Comment:
I think that the expression, as originally provided, is subject to the following bug: that final \S+ matches strings that end with, say punctuation. To see the issue, suppose that we are searching for URLs in the source text "blah blah blah (http://www.ibm.com) blah blah blah". Then that expression will report "http://www.ibm.com)" as the URL, which is wrong, as it includes the final parentheses. One possible fix is to use negative look behind to restrict matches from ending in punctuation. The current URL regex that I am using (with Java's regex engine) is "(?:(?:mailto\\:|(?:news|(?:ht|f)tp(?:s?))\\://){1}\\S+)" + "(?<!\\p{Punct})" That seems to do the trick for me for MY PARTICULAR URLs. WARNING: this is not a general cure all, since there are valid URLs which end in punctuation. For instance, a final underscore ('_') char should be fine. Perhaps a better more general solution would be to replace "(?<!\\p{Punct})" with something less broad, like "(?<![^,^\\)^\\]^\\}])" Please post back with any feedback.


Title: Bug!
Name: Brent Boyer
Date: 1/7/2010 3:01:16 PM
Comment:
I think that the expression, as originally provided, is subject to the following bug: that final \S+ matches strings that end with, say punctuation. To see the issue, suppose that we are searching for URLs in the source text "blah blah blah (http://www.ibm.com) blah blah blah". Then that expression will report "http://www.ibm.com)" as the URL, which is wrong, as it includes the final parentheses. One possible fix is to use negative look behind to restrict matches from ending in punctuation. The current URL regex that I am using (with Java's regex engine) is "(?:(?:mailto\\:|(?:news|(?:ht|f)tp(?:s?))\\://){1}\\S+)" + "(?<!\\p{Punct})" That seems to do the trick for me for MY PARTICULAR URLs. WARNING: this is not a general cure all, since there are valid URLs which end in punctuation. For instance, a final underscore ('_') char should be fine. Perhaps a better more general solution would be to replace "(?<!\\p{Punct})" with something less broad, like "(?<![^,^\\)^\\]^\\}])" Please post back with any feedback.


Title: Bug!
Name: Brent Boyer
Date: 1/7/2010 2:54:10 PM
Comment:
I think that the expression, as originally provided, is subject to the following bug: that final \S+ matches strings that end with, say punctuation. To see the issue, suppose that we are searching for URLs in the source text "blah blah blah (http://www.ibm.com) blah blah blah". Then that expression will report "http://www.ibm.com)" as the URL, which is wrong, as it includes the final parentheses. One possible fix is to use negative look behind to restrict matches from ending in punctuation. The current URL regex that I am using (with Java's regex engine) is "(?:(?:mailto\\:|(?:news|(?:ht|f)tp(?:s?))\\://){1}\\S+)" + "(?<!\\p{Punct})" That seems to do the trick for me for MY PARTICULAR URLs. WARNING: this is not a general cure all, since there are valid URLs which end in punctuation. For instance, a final underscore ('_') char should be fine. Perhaps a better more general solution would be to replace "(?<!\\p{Punct})" with something less broad, like "(?<![^,^\\)^\\]^\\}])" Please post back with any feedback.


Title: Failure on missing extension
Name: Mike
Date: 6/24/2009 12:31:25 PM
Comment:
allowed http://yourmoma


Title: how to handle special characters like ^ in URL?
Name: charandeep
Date: 8/19/2008 6:35:24 AM
Comment:
Hi, Please let me know how i can prevent special characters like "^". Thanks, Charandeep


Title: gsdfh
Name: dhdf
Date: 12/15/2004 7:39:54 PM
Comment:
went to www.bbc.co.uk site


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