Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
(^[a-zA-Z0-9]+://) |
Description |
Use in a .net Regex.Split() to pull the protocol out of a url into the first array entry. |
Matches |
myprot://server/path.asp |
Non-Matches |
server/path.asp |
Author |
Rating:
Not yet rated.
blake wolf
|
Title |
Test
Details
Label all parts of a URL
|
Expression |
(?:(?<protocol>http(?:s?)|ftp)(?:\:\/\/))
(?:(?<usrpwd>\w+\:\w+)(?:\@))?
(?<domain>[^/\r\n\:]+)?
(?<port>\:\d+)?
(?<path>(?:\/.*)*\/)?
(?<filename>.*?\.(?<ext>\w{2,4}))?
(?<qrystr>\??(?:\w+\=[^\#]+)(?:\&?\w+\=\w+)*)*
(?<bkmrk>\#.*)? |
Description |
I needed a regular expression to break urls into labled parts. This is what I came up with. Got a few ideas from regexlib.com and from this msdn article. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/reconbackreferences.asp
http://www.domain.com/folder does return a match but will not grab the folder name unless there is "/" at the end.
http://www.domain.com/folder/ |
Matches |
https://192.168.0.2:80/users/~fname.lname/file.ext | ftp://user1: [email protected] | http://www.dom |
Non-Matches |
|
Author |
Rating:
Ariel Merrell
|
Title |
Test
Details
Pattern Title
|
Expression |
[a-zA-Z]{3,}://[a-zA-Z0-9\.]+/*[a-zA-Z0-9/\\%_.]*\?*[a-zA-Z0-9/\\%_.=&]* |
Description |
A simple url search pattern that works against the most generic cases. A little better in terms of matches than the other URL expressions listed. |
Matches |
http://someserver | http://www.someserver.com/ | http://www.someserver.com/somefile.txt |
Non-Matches |
Thin | Lizzy |
Author |
Rating:
Not yet rated.
Gerrard Lindsay
|
Title |
Test
Details
Pattern Title
|
Expression |
(\s|\n|^)(\w+://[^\s\n]+) |
Description |
will match free floating valid protocol + urls in text ... will not touch the ones wrapped in a tag, so that you can auto-link the ones that aren't :) couple of things to know :
1. if the url is next to a tag this won't work (eg : <br>http://www.acme.com), the url must either start with a \s, \n or any character other than >.
2. the pattern will match the preceding \s and \n too, so when you replace put them back in place $1 will either be \s or \n, $2 will be the exact match
vb usage :
set re = New RegExp
re.Pattern ="(\s|\n|^)(\w+://[^\s\n]+)"
strResult = re.Replace(strText, "$1<a href='$2' target='_new'>$2</a>") |
Matches |
http://www.acme.com | ftp://ftp.acme.com/hede | gopher://asdfasd.asdfasdf |
Non-Matches |
<a href="http://acme.com">http://www.acme.com</a> | <br>http://www.acme. |
Author |
Rating:
ic onur
|
Title |
Test
Details
Pattern Title
|
Expression |
^(ht|f)tp(s?)\:\/\/[a-zA-Z0-9\-\._]+(\.[a-zA-Z0-9\-\._]+){2,}(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$ |
Description |
Cheap and cheerful URL checker. Requires a http/https/ftp at the start and will then allow anything starting with at least a <something>.<something>.<something> then valid characters separated by dots and slashes |
Matches |
http://www.thedaddy.org | http://forum.thedaddy.org/index.html | ftp://hows.it.going_buddy/checkit/o |
Non-Matches |
www.thedaddy.org | http://hello | ftp://check.it |
Author |
Rating:
John Main
|
Title |
Test
Details
Pattern Title
|
Expression |
^((((H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$ |
Description |
Matches URLS that start with numbers and any TLD that is 2 to 6 characters long. Matches most URLs. Thanks to eveyone for suggesting modifications!
UPDATES::[Nov. 11, 2005] Now it matches uppercase and lower case protocols.
Updates::December 3, 2005 Added restriction to ports since they will only go up to 65535. (Thanks lorello)
Keep the suggestions coming! Thanks for the heads up!! |
Matches |
hTtP://3iem.net/ | http://3iem.museum:1337/ | plik.co.uk |
Non-Matches |
http://foobar | lameurl.toolongtld |
Author |
Rating:
Phil Cogbill
|
Title |
Test
Details
Pattern Title
|
Expression |
^((ht|f)tp(s?))\://([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(/\S*)?$ |
Description |
Simple URL Validator -- allows http, https, ftp, ftps, 2-6 letter TLD, ports, any path. Sorry, no IP addresses. Not too fussy, but then, it's not too long either ;-) |
Matches |
http://www.site.com | https://www.secure.com:10000 | ftp://ftp.site.com/pub/files/ |
Non-Matches |
www.site.com | https://www.site.longtld | ftp:/badformat.com |
Author |
Rating:
Luke Arms
|
Title |
Test
Details
Pattern Title
|
Expression |
((ht|f)tp(s?))(:((\/\/)(?!\/)))(((w){3}\.)?)([a-zA-Z0-9\-_]+(\.(com|edu|gov|int|mil|net|org|biz|info|name|pro|museum|co\.uk)))(\/(?!\/))(([a-zA-Z0-9\-_\/]*)?)([a-zA-Z0-9])+\.((jpg|jpeg|gif|png)(?!(\w|\W))) |
Description |
This expression matches valid image URLs. The main use for this would be in UBBC tags.
Written by RyanJ and Jick for FWD (http://flexwebdev.thenamesdan.com/) |
Matches |
http://www.location.com/images/image1.gif | http://www.location.com/images/mainImgs/image1.png |
Non-Matches |
/images/image1.jpeg | http://www.location.com/images/image1.swf | http://www.something.com/hello/..j |
Author |
Rating:
Ryan Jones
|
Title |
Test
Details
Pattern Title
|
Expression |
<\s*a\s[^>]*\bhref\s*=\s*
('(?<url>[^']*)'|""(?<url>[^""]*)""|(?<url>\S*))[^>]*>
(?<body>(.|\s)*?)<\s*/a\s*> |
Description |
Suitable for extraction of all hyperlinks in the format:
<a ... href="..." ...> some text </a>
from a text document. Separates in groups the components of the links (url and body). |
Matches |
<a href="javascript:'window.close()'">close the window</a> | <a target=&quo |
Non-Matches |
<aa href="test.htm">test</a> | < a href hr = 'http://www.nakov.com'>...& |
Author |
Rating:
Svetlin Nakov
|
Title |
Test
Details
Pattern Title
|
Expression |
^(?<link>((?<prot>http:\/\/)*(?<subdomain>(www|[^\-\n]*)*)(\.)*(?<domain>[^\-\n]+)\.(?<after>[a-zA-Z]{2,3}[^>\n]*)))$ |
Description |
I wrote this after I couldn't find an expression that would search for valid URLs, whether they had HTTP in front or not. This will find those that don't have hyphens anywhere in them (except for after the domain). |
Matches |
http://www.google.com | www.123google.com | www.google.com/help/me |
Non-Matches |
-123google.com | http://-123.123google.com |
Author |
Rating:
Not yet rated.
Joe Pontani
|
Title |
Test
Details
Pattern Title
|
Expression |
(^[a-zA-Z][a-zA-Z0-9_]*)|(^[_][a-zA-Z0-9_]+) |
Description |
This pattern can be used for validating a string as a valid element name (e.g. variable or class name) in Microsoft .NET. See also http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vbconelementnames.asp |
Matches |
var | _withunder_score99 | TeSt |
Non-Matches |
_ | 123abc | 9 |
Author |
Rating:
Not yet rated.
Howard Richards
|
Title |
Test
Details
Pattern Title
|
Expression |
(((ht|f)tp(s?):\/\/)|(www\.[^ \[\]\(\)\n\r\t]+)|(([012]?[0-9]{1,2}\.){3}[012]?[0-9]{1,2})\/)([^ \[\]\(\),;"'<>\n\r\t]+)([^\. \[\]\(\),;"'<>\n\r\t])|(([012]?[0-9]{1,2}\.){3}[012]?[0-9]{1,2}) |
Description |
v2
A general purpose expresion to find url's (improved).
Add heads to first part, example:
((imap:|(ht|f)tp(s?):\/\/)|(www\.
to find url's like imap://www.com/, so ip's. No ipv6 (yet) |
Matches |
www.domain.com | http://www.blah.ru | https://192.168.0.2:80/users/~fname.lname/file.ext |
Non-Matches |
imap://.com |
Author |
Rating:
Not yet rated.
James Tikitiki
|
Title |
Test
Details
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:
James Johnston
|
Title |
Test
Details
Pattern Title
|
Expression |
href\s*=\s*(?:(?:\"(?<url>[^\"]*)\")|(?<url>[^\s*] ))>(?<title>[^<]+)</\w> |
Description |
finds the url and url description for all links in a given text. |
Matches |
<td bgcolor="#ffffff" class="small">&nbsp;<A HREF=" http:// |
Non-Matches |
<td bgcolor="#ffffff" class="small">&nbsp;<A HREF http://www.thepla |
Author |
Rating:
Not yet rated.
Matt Bruce
|
Title |
Test
Details
Pattern Title
|
Expression |
\b([\d\w\.\/\+\-\?\:]*)((ht|f)tp(s|)\:\/\/|[\d\d\d|\d\d]\.[\d\d\d|\d\d]\.|www\.|\.tv|\.ac|\.com|\.edu|\.gov|\.int|\.mil|\.net|\.org|\.biz|\.info|\.name|\.pro|\.museum|\.co)([\d\w\.\/\%\+\-\=\&\?\:\\\"\'\,\|\~\;]*)\b |
Description |
Url matching |
Matches |
http://210.50.2.215/sd_new/WebBuilder.cgi?RegID=7449046&First=Ok&Upt=Ok&EditPage=3&S |
Non-Matches |
Hmmmm |
Author |
Rating:
Johky Cheng
|
Title |
Test
Details
Pattern Title
|
Expression |
^(((ht|f)tp(s?))\://)?((([a-zA-Z0-9_\-]{2,}\.)+[a-zA-Z]{2,})|((?:(?:25[0-5]|2[0-4]\d|[01]\d\d|\d?\d)(?(\.?\d)\.)){4}))(:[a-zA-Z0-9]+)?(/[a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~]*)?$ |
Description |
Hopefully an all-encompassing expression to validate a URL. Supports an optional protocol, either a domain or IP address, an optional port number and an optional path. |
Matches |
this.com | https://this.com:8080/this/this.htm | ftp://255.255.255.255/ |
Non-Matches |
.this.com | https://this.com:/ | ftps://255.256.255.255/ |
Author |
Rating:
Tom Hartland
|
Title |
Test
Details
Pattern Title
|
Expression |
([^\=&]+)(?<!param1|param2|param3)\=([^\=&]+)(&)? |
Description |
this regex eleminates all parameters from a html querry e.g.
param1=hans&param2=5&badparam=5
so bad param will be deleted from the params given. its usefull to clean up urls from unwanted params you not allow befor using the query string for further issues. |
Matches |
param1=2¶m2=2¶m3=5¶m4=9 |
Non-Matches |
none |
Author |
Rating:
Not yet rated.
Ludwig Gramberg
|
Title |
Test
Details
Pattern Title
|
Expression |
(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\.))+(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9\&%_\./-~-]*)? |
Description |
You can use this regular expression in your PHP scripts to convert entered URL in text to URL link. Example:
$text=ereg_replace("(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\.))+(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9\&%_\./-~-]*)?","<a href=\"./redir.php?url=\\0\" target=\"_blank\">\\0</a>",$text); |
Matches |
http://diskusneforum.sk | www.diskusneforum.sk | ftp://123.123.123.123/ |
Non-Matches |
diskusneforum.sk |
Author |
Rating:
Martin Ille
|
Title |
Test
Details
Pattern Title
|
Expression |
^[http://www.|www.][\S]+$ |
Description |
a simple url validation |
Matches |
http://www.regexlib.com/Add.aspx | www.regexlib.com/Add.aspx |
Non-Matches |
regexlib.com/Add.aspx |
Author |
Rating:
Not yet rated.
Rahul Bhot
|
Title |
Test
Details
URL
|
Expression |
^((([hH][tT][tT][pP][sS]?|[fF][tT][pP])\:\/\/)?([\w\.\-]+(\:[\w\.\&%\$\-]+)*@)?((([^\s\(\)\<\>\\\"\.\[\]\,@;:]+)(\.[^\s\(\)\<\>\\\"\.\[\]\,@;:]+)*(\.[a-zA-Z]{2,4}))|((([01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}([01]?\d{1,2}|2[0-4]\d|25[0-5])))(\b\:(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0)\b)?((\/[^\/][\w\.\,\?\'\\\/\+&%\$#\=~_\-@]*)*[^\.\,\?\"\'\(\)\[\]!;<>{}\s\x7F-\xFF])?)$ |
Description |
Matches a URL string by: protocol,subdomain,domain,ip address,port number,path and/or filename |
Matches |
http://regexlib.com | https://regexlib.com:80 | 66.129.120.94/Search.aspx |
Non-Matches |
http:/regexlib.com | https://regexlib.com:65536 | 66.129.120.256/Search.aspx. |
Author |
Rating:
Not yet rated.
Dean Dal Bozzo
|
Displaying page
of
pages;
Items to