74 regular expressions found in this category!
Displaying page
of
pages;
Items to
| Title |
Test
Details
Pattern Title
|
| Expression |
^((\d|\d\d|[0-1]\d\d|2[0-4]\d|25[0-5])\.(\d|\d\d|[0-1]\d\d|2[0-4]\d|25[0-5])\.(\d|\d\d|[0-1]\d\d|2[0-4]\d|25[0-5])\.(\d|\d\d|[0-1]\d\d|2[0-4]\d|25[0-5]))$
|
| Description |
Matches valids TCP/IP-Adresses |
| Matches |
1.198.0.1 | 100.10.0.1 | 200.200.123.123 |
| Non-Matches |
..12.23 | a.23.345 | 400.500.300.300 |
| Author |
Rating:
Karsten Sosna
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^([a-zA-Z]\:)(\\[^\\/:*?<>"|]*(?<![ ]))*(\.[a-zA-Z]{2,6})$ |
| Description |
Matches filenames.
UPDATED on 1st Jan 2004. |
| Matches |
C:\di___r\fi_sysle.txt | c:\dir\filename.txt |
| Non-Matches |
c:\dir\file?name.txt |
| Author |
Rating:
Darren Neimke
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$ |
| Description |
Checks domain names. This validates domains based on latest specifications (RFCs 952 and 1123 dealing with hostnames and RFC 1035 dealing with domain name system requirements) except that it only includes realistic fully-qualified domains: 1. requires at least one subdomain 2. allows shortest top-level domains like "ca", and "museum" as longest.
Other validation rules: 1. Labels/parts should be seperated by period. 2. Each label/part has maximum of 63 characters. 3. First and last character of label must be alphanumeric, other characters alphanumeric or hyphen. 4. Does not check maxlength of domain which incidentally is 253 characters of text (255 binary representation).
For a regular expression that matches ALL domains:
^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?$
|
| Matches |
regexlib.com | this.is.a.museum | 3com.com |
| Non-Matches |
notadomain-.com | helloworld.c | .oops.org |
| Author |
Rating:
Remi Sabourin
|
| 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:pwd@www.domain.com | http://www.dom |
| Non-Matches |
www.domain.com | user1:pwd@domain.com | 192.168.0.2/folder/file.ext |
| Author |
Rating:
Ariel Merrell
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(((ht|f)tp(s?))\://)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+\.(com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk)(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$ |
| Description |
Version 1.3.0: I needed a regexp to validate URL's without the ht(f)tp(s):// and include North American domains (like .us and .ca) and there didn't seem to be one available...so I created one. It will also work with ASP QueryStrings and anchor URL's. If you have a problem with the expression or have any suggestions to improve, please write me and let me know. Added .uk domain and expression now allows for URLs that contain JSP session IDs. 4/14/04 - added ability to include URLs that start with server names. |
| Matches |
www.blah.com:8103 | www.blah.com/blah.asp?sort=ASC | www.blah.com/blah.htm#blah |
| Non-Matches |
www.state.ga | http://www.blah.ru |
| Author |
Rating:
Brad Dobyns
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(\$)?(([1-9]\d{0,2}(\,\d{3})*)|([1-9]\d*)|(0))(\.\d{2})?$ |
| Description |
Modified Joe Lynwood's to allow zero amounts. Handles US Dollars including zero dollars. |
| Matches |
$1,234,567.89 | 1234567.89 | $0.00 |
| Non-Matches |
$1,2345,67.89 | $1234,345,678.0 |
| Author |
Rating:
Jason Roe
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^\\{2}[\w-]+\\(([\w-][\w-\s]*[\w-]+[$$]?$)|([\w-][$$]?$)) |
| Description |
Validates a UNC to conform to \\server\service
Must have a "\\" at the start
Server may contain alpha/numeric/underscore/dash,
Followed by another single "\"
Service may contain alpha/numeric/underscore/dash/$/space
Note:
Service may not start nor end with a space
Service may only contain one $, and only at the end
No additional "\" may follow afterwards
|
| Matches |
\\server\service | \\server\my service | \\serv_001\service$ |
| Non-Matches |
\\my server\service | \\server\ service | \\server$\service |
| Author |
Rating:
Paul Haines
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^([a-zA-Z].*|[1-9].*)\.(((j|J)(p|P)(g|G))|((g|G)(i|I)(f|F)))$ |
| Description |
Regular expression to limit types of files accepted. This example matches .jpg and .gif files only. |
| Matches |
filename.jpg | FileName.JPG | filename.gif |
| Non-Matches |
filename.png | filename.xxx | filename.bmp |
| Author |
Rating:
Ramon Hildreth
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^([a-zA-Z]\:) (\\{1}| ((\\{1}) [^\\] ([^/:*?<>"|]*(?<![ ])))+)$ |
| Description |
Validates windows path and invalidates UNC path |
| Matches |
c:\34\445\546\3.htm | C:\ |
| Non-Matches |
\\qaz | c:\Ram<\ | C: or c:\\ or \\ |
| Author |
Rating:
Gaurav Shrivastava
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$ |
| Description |
RegExp for validating the format of IP Addresses. This works great with the ASP.NET RegularExpressionValidator server control. |
| Matches |
127.0.0.1 | 255.255.255.0 | 192.168.0.1 |
| Non-Matches |
1200.5.4.3 | abc.def.ghi.jkl | 255.foo.bar.1 |
| Author |
Rating:
G. Andrew Duthie
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$ |
| Description |
Ok here's an updated URL regex for you folks. It allows localhost and all TLDs. Feel free to add each country code individually if you want a tighter match. |
| Matches |
http://site.com/dir/file.php?var=moo | https://localhost | ftp://user:pass@site.com:21/file/dir |
| Non-Matches |
site.com | http://site.com/dir// |
| Author |
Rating:
Brian Bothwell
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])? |
| Description |
*CORRECTED: Again thanks for all the comments below. If you want to include internal domain as well change the partial code (\.[\w-_]+)+ to (\.[\w-_]+)?
See the comments below*
This is the regular expression I use to add links in my email program. It also ignores those suppose-to-be commas/periods/colons at the end of the URL, like this sentence "check out http://www.yahoo.com/." (the period will be ignored) Note that it requires some modification to match ones that dont start with http. |
| Matches |
http://regxlib.com/Default.aspx | http://electronics.cnet.com/electronics/0-6342366-8-8994967-1.html |
| Non-Matches |
www.yahoo.com |
| Author |
Rating:
M H
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(ht|f)tp((?<=http)s)?://((?<=http://)www|(?<=https://)www|(?<=ftp://)ftp)\.(([a-z][0-9])|([0-9][a-z])|([a-z0-9][a-z0-9\-]{1,2}[a-z0-9])|([a-z0-9][a-z0-9\-](([a-z0-9\-][a-z0-9])|([a-z0-9][a-z0-9\-]))[a-z0-9\-]*[a-z0-9]))\.(co|me|org|ltd|plc|net|sch|ac|mod|nhs|police|gov)\.uk(:\d+)?\/?$ |
| Description |
UK http/https/ftp URI. Based on my previous expression, this one takes an optional port number and optional trailing slash. |
| Matches |
http://www.zeropanic.co.uk/ | http://www.zeropanic.co.uk:81/ | http://www.zeropanic.co.uk:81 |
| Non-Matches |
http://www.zeropanic.com:81/ |
| Author |
Rating:
Amos Hurd
|
| Title |
Test
Details
Pattern Title
|
| Expression |
\.com/(\d+)$ |
| Description |
This is a regex I wrote to capture requests to AspAlliance.com with an article id as the only thing after the domain. So http://aspalliance.com/123 would go to article number 123. It maps the URL to the actual aspx file that displays the article based on the ID. |
| Matches |
http://aspalliance.com/123 | www.aspalliance.com/123 | http://aspalliance.com/34 |
| Non-Matches |
http://aspalliance.com/article.aspx?id=123 | http://aspalliance.com/ | http://aspalliance.com/articl |
| Author |
Rating:
Steven Smith
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(ht|f)tp((?<=http)s)?://((?<=http://)www|(?<=https://)www|(?<=ftp://)ftp)\.(([a-z][0-9])|([0-9][a-z])|([a-z0-9][a-z0-9\-]{1,2}[a-z0-9])|([a-z0-9][a-z0-9\-](([a-z0-9\-][a-z0-9])|([a-z0-9][a-z0-9\-]))[a-z0-9\-]*[a-z0-9]))\.(co|me|org|ltd|plc|net|sch|ac|mod|nhs|police|gov)\.uk$ |
| Description |
UK domains with protocol for http/https/ftp. Based on my previous expression, this allows the subdomain "www" for the http/https protocols, or "ftp" for the ftp protocol only. |
| Matches |
http://www.zeropanic.co.uk | ftp://ftp.sunsite.ac.uk | https://www.z2.co.uk |
| Non-Matches |
gopher://www.z2.co.uk | http://ftp.z2.co.uk | ftp://www.z2.co.uk |
| Author |
Rating:
Amos Hurd
|
| 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 |
^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*.*))+\.(jpg|JPG)$ |
| Description |
It matches .jpg files. It allows for a dot in the path. A dot may occur in such directories as: C:\Documents and Settings\roman.lukyanenko\Desktop\stuff\b_card2.jpg
or C:\Windows\Microsoft.NET etc |
| Matches |
C:\Documents and Settings\roman.lukyanenko\Desktop\stuff\b_card2.jpg | C:\b_card.jpg | \\network\fol |
| Non-Matches |
C:\file.xls |
| Author |
Rating:
Roman Lukyanenko
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(?<http>(http:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*) |
| Description |
This is HTTP Url extractor |
| Matches |
http://www.abc.com | www.mpgrewal.tk |
| Non-Matches |
noida-India | crazy123 |
| Author |
Rating:
Manpreet Grewal
|
| Title |
Test
Details
Pattern Title
|
| Expression |
[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} |
| Description |
Very Simple Match for dotted Decimal IP address. Doesn’t Validate addresses |
| Matches |
192.168.1.1 | 10.2.234.1 | 66.129.71.122 |
| Non-Matches |
192.168.1 | 10.2.1234.1 | 66 129 71 122 |
| Author |
Rating:
David Tersigni
|
Displaying page
of
pages;
Items to