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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Matching urls in free text
Expression
((www|http)(\W+\S+[^).,:;?\]\} \r\n$]+))
Description
A regular expression which allows me to find strings of text floating around in free text that are in fact URLs. I need to tag these as <url>www.bmj.com/advice</url>. The problem has been allowing special characters in the url, but not mixing them up with genuine punctuation marks at the end of the url in the text-e.g. '.' or '?' or ) or ';' etc)
Matches
www.bmjpg.com/advice&search=?light+dark
Non-Matches
www.bmjpg.com/advice&search=?light+dark?
Author Rating: The rating for this expression. Sean Harrop
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: Need regex to allow new line '\n' characters in java
Name: Need regex to allow new line '\n' characters in java
Date: 6/12/2015 2:03:06 AM
Comment:
Need regex to allow new line '\n' characters in java


Title: Nice!
Name: clickfast
Date: 5/30/2007 5:45:34 PM
Comment:
I want to locate the full URLs with the domain media.myspace.com in them. Here is the text: <?xml version="1.0" encoding="iso-8859-1"?> <profile> <timestamp><![CDATA[1178550629]]></timestamp> <name><![CDATA[305musik]]></name> <playstoday><![CDATA[139]]></playstoday> <downloadedtoday><![CDATA[0]]></downloadedtoday> <totalplays><![CDATA[16466]]></totalplays> <autoplay><![CDATA[2]]></autoplay> <allowadd><![CDATA[1]]></allowadd> <playlist><song bsid="57188285" title="Goonsville" songid="23172069" plays="818" comments="23172069" rate="23172069" downloadable="" imagename="http://a689.ac-images.myspacecdn.com/02024/88/64/2024424688_m.gif" imagedesc="The Revelations&lt;br&gt;2007" filename="Q51/Kgx9v3esrZh68buxzhKPhaSK/oyTR4Gr9RZ3ago2bHtx6P98H+DF8V2eCC89p+5kbWHQRSFK0VlaIAQ9kKFzPXxo7lyvyGJnVMbBELs=" url="http://media.myspace.com/services/media/mediahitcounter.ashx?i=MIGdBgorBgEEAYI3WAO2oIGOMIGLBgorBgEEAYI3WAMBoH0wewIDAgABAgJmAwICAMAECLQvTrb00wUwBBCgE4K7%2f9u%2bF7bedwR0sx6HBFDigRCgMSDiYl4eYBIB2BW7Z81XwT1tz98XECRVSl%2bBh9dMdTiOICOEWo4PVHDqr36SRJkuY6xyHtf29I2pIJCtYcC9Tr1YNo9otgCDkk4WVQ%3d%3d" lyrics="" purl="" durl="http://cache02-music02.myspacecdn.com/11/std_3f8707ee48b908df55f36090c45cfde7.mp3" token="qkZDR2Bu2AyFBRqX9h3u2BiR2+KD2Y3wujhxda9vn5BgdpEVF+p2G7fR95Houy0TTwrDuR//lQt6CkTZOpuU4huUKivO9hT0q3fb3QjP0jI=" curl="http://cache02-music02.myspacecdn.com/11/std_3f8707ee48b908df55f36090c45cfde7.mp3?bandid=142771669&amp;songid=57188285&amp;p=OTYvNjEvMTQyNzcxNjY5LzE0Mjc3MTY2OV85ODg3M2YwYw=="/><song bsid="57379790" title="Rafee" songid="23251045" plays="814" comments="23251045" rate="23251045" downloadable="" imagename="http://a243.ac-images.myspacecdn.com/02024/24/24/2024754242_m.gif" imagedesc="El Q Vale Lo Q Pesa En Oro 2007&lt;br&gt;2007" filename="Sq+yqRrSGA3ZhZjSP9Hdc8DA7J+G+aTgMtmyPL0M47G0R0poBojWReolpqoNXp6hsMoRjKPehlFEA11hoc8XtGXiHQ2IbxhO3s6NQd6ab08=" url="http://media.myspace.com/services/media/mediahitcounter.ashx?i=MIGdBgorBgEEAYI3WAO2oIGOMIGLBgorBgEEAY


Title: short and sweet
Name: sanj
Date: 6/16/2006 10:28:06 AM
Comment:
this one is cute !


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