Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
^\d{9}[\d|X]$ |
Description |
A very simple ISBN validation expression - it just checks for a 10 digit number where the last digit could also be a capital 'X'. Complete specs for ISBN available here:
http://www.isbn.org/standards/home/isbn/international/html/usm4.htm. An enhancement would be to allow exactly 3 or 0 hyphens or 3 or 0 spaces, since these are also valid formats. |
Matches |
1234123412 | 123412341X |
Non-Matches |
not an isbn |
Author |
Rating:
Not yet rated.
Steven Smith
|
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 |
^\d{5}(-\d{3})?$ |
Description |
Matches standard 5 digit Brazilian Postal Codes (CEP), or the CEP + 3 digits (distribution identifiers - suffix).
For more info refer to: http://www.correios.com.br/servicos/cep/Estrutura_CEP.cfm (in portuguese). |
Matches |
13165-000 | 38175-000 | 81470-276 |
Non-Matches |
13165-00 | 38175-abc | 81470-2763 |
Author |
Rating:
Not yet rated.
Carlos Nascimento
|
Title |
Test
Details
Pattern Title
|
Expression |
^([A-Z]{1,2}[0-9]{1,2}|[A-Z]{3}|[A-Z]{1,2}[0-9][A-Z])( |-)[0-9][A-Z]{2} |
Description |
Checks whether the string specified is in the same format as the UK postcode format defined on:
http://www.magma.ca/~djcl/postcd.txt
It allows:
A = Letter
N = Number
AN NAA, ANA NAA, ANN NAA, AAN NAA, AAA NAA (rare), AANN NAA, AANA NAA
It gives the option to have the two parts of the uk postcode to be separated by a space or a hyphen.
(restriction is set to all-capitals) |
Matches |
AA11 1AA | AA1A 1AA | A11-1AA |
Non-Matches |
111 AAA | 1AAA 1AA | A1AA 1AA |
Author |
Rating:
Not yet rated.
Henk de Vries
|
Title |
Test
Details
Pattern Title
|
Expression |
^([0]?[1-9]|[1|2][0-9]|[3][0|1])[./-]([0]?[1-9]|[1][0-2])[./-]([0-9]{4}|[0-9]{2})$ |
Description |
Validate brazilian date formats: dd/mm/yyyy or d/m/yy or d.m.yyyy
with separators: . - /
Valid dates only! d (1-31)/ m (1-12)/ y (0..)
(rizzipereira.com.br)
For American date format: http://www.regexlib.com/REDetails.aspx?regexp_id=932 |
Matches |
10/03/1979 | 1-1-02 | 01.1.2003 |
Non-Matches |
10/03/197 | 09--02--2004 | 01 02 03 |
Author |
Rating:
Diego dos Santos
|
Title |
Test
Details
Pattern Title
|
Expression |
(\[[Ii][Mm][Gg]\])(\S+?)(\[\/[Ii][Mm][Gg]\]) |
Description |
easy when you want to allow your users to post images, but in a controlled way. I used it like this (in php):
$text = preg_replace("/(\[IMG\])(\S+?)(\[\/IMG\])/is", "<a href=\"\\2\" target=\"_blank\"><IMG SRC=\"\\2\" align=\"center\" height=\"100\" border=\"0\"></a>",$text);
so whenever they use
[img]http://www.foo.com/bleh.jpg[/img]
it will be converted to
<a href="http://www.foo.com/bleh.jpg" target="_blank"><IMG SRC="http://www.foo.com/bleh.jpg" align="center" height="100" border="0"></a>
so you get a 100 pixels high picture, and when they click on it it opens in a new window...
(to prevent users from posting huge pictures and stuff) |
Matches |
[IMG]http://bleh.jpg[/IMG] | [ImG]bleh[/imG] | [img]ftp://login: [email protected][/img] |
Non-Matches |
<img src="bleh.jpg"> |
Author |
Rating:
marnik vander elst
|
Title |
Test
Details
Pattern Title
|
Expression |
(^|\s)(00[1-9]|0[1-9]0|0[1-9][1-9]|[1-6]\d{2}|7[0-6]\d|77[0-2])(-?|[\. ])([1-9]0|0[1-9]|[1-9][1-9])\3(\d{3}[1-9]|[1-9]\d{3}|\d[1-9]\d{2}|\d{2}[1-9]\d)($|\s|[;:,!\.\?]) |
Description |
Incorporated other people's examples; removed extraneous parenthesis on 10/7/04. Currently the SSA site says 772 is the highest AREA number generated (http://www.ssa.gov/employer/highgroup.txt). Old expression was: (^|\s)\d{3}(-?|[\. ])\d{2}\2\d{4}($|\s|[;:,!\.\?]). Looks for either the beginning of a line or whitespace before the beginning of the social security number, then either zero or one hyphen OR one of a period or space, then uses the \3 to reference the value returned in the parenthesis that includes the -?|[\. ] (basically says if the first dash, period, or space is there, then the second one is required; and if the first dash, period, or space is not there, then the second one can't be either), and finally looks for the end of a line, whitespace, or punctuation characters after the social security number. |
Matches |
123-45-6789 | 123 45 6789 | 123456789 |
Non-Matches |
12345-67-890123 | 1234-56-7890 | 123-45-78901 |
Author |
Rating:
Dennis Flynn
|
Title |
Test
Details
Pattern Title
|
Expression |
(?s)(?:\e\[(?:(\d+);?)*([A-Za-z])(.*?))(?=\e\[|\z) |
Description |
This expression will match all of the commands(escape codes) used in ANSI files. These are what were used to create the colors/blocks on BBS's for those of us that once dialed into them.
http://www.wikipedia.org/wiki/ANSI_escape_code has a reference for ANSI escape codes.
http://idledreams.net/lordscarlet/posts/153.aspx shows an example of the engine I have created surrounding the expression |
Matches |
[32mHello | [1;35mTest | [2J |
Non-Matches |
abc |
Author |
Rating:
Not yet rated.
Doug Moore
|
Title |
Test
Details
Pattern Title
|
Expression |
\d{1,3}.?\d{0,3}\s[a-zA-Z]{2,30}\s[a-zA-Z]{2,15} |
Description |
Street Address. While far from perfect it validates street addresses reasonably. Created with absolutely no experience using a cool tool downloaded from http://www.codeproject.com/dotnet/expresso.asp?target=e%20xpresso |
Matches |
2\34 Wodonga Ave | 54a Beechworth Rd | 47/675 WODONGA DRIVE |
Non-Matches |
aaa Beechworth Rd | 65 Beechworth Rd | 65 Beechworth/ Rd |
Author |
Rating:
adam willding
|
Title |
Test
Details
U.S. Street Address
|
Expression |
^(?n:(?<address1>(\d{1,5}(\ 1\/[234])?(\x20[A-Z]([a-z])+)+ )|(P\.O\.\ Box\ \d{1,5}))\s{1,2}(?i:(?<address2>(((APT|B LDG|DEPT|FL|HNGR|LOT|PIER|RM|S(LIP|PC|T(E|OP))|TRLR|UNIT)\x20\w{1,5})|(BSMT|FRNT|LBBY|LOWR|OFC|PH|REAR|SIDE|UPPR)\.?)\s{1,2})?)(?<city>[A-Z]([a-z])+(\.?)(\x20[A-Z]([a-z])+){0,2})\, \x20(?<state>A[LKSZRAP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADL N]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD] |T[NX]|UT|V[AIT]|W[AIVY])\x20(?<zipcode>(?!0{5})\d{5}(-\d {4})?))$ |
Description |
captures US street address.
Address format: ##### Street 2ndunit City, ST zip+4
address1 - must have street number and proper case street name. no punctuation or P.O Box #### punctuation manditory for P.O.
address2 - optional secondary unit abbr. Secondary range required for some units.
City - Proper case city name.
State - State abbreviation. All caps
zip - zip+4. Can't be all zeroes
Abbreviations for secondary units and States are those used by the US Postal Service.
http://www.usps.com/ncsc/lookups/usps_abbreviations.html
Certain secondary units require a secondary range, see the above link
THis RE isn't unbreakable, Probably will allow some false positives but should work for most addresses. |
Matches |
123 Park Ave Apt 123 New York City, NY 10002 | P.O. Box 12345 Los Angeles, CA 12304 |
Non-Matches |
123 Main St | 123 City, State 00000 | 123 street city, ST 00000 |
Author |
Rating:
Michael Ash
|
Title |
Test
Details
Pattern Title
|
Expression |
^\s*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$ |
Description |
Matches UK phone numbers - London and regional. It started off with something fairly short posted by liljim at www.forums.devshed.com but I wanted a little more precision to weed out all the zeros. Now it also weeds out premium phone numbers (as of 19/12/03). |
Matches |
02071111111 | 01000100000 |
Non-Matches |
00000000000 |
Author |
Rating:
M h
|
Title |
Test
Details
Pattern Title
|
Expression |
^DOMAIN\\\w+$ |
Description |
In response to a question on the regex list at www.aspadvice.com, this expression should ensure that a login field's username includes a 'DOMAIN\' prefix. The latter part of the expression should probably be limited so that it only allows usernames of appropriate lengths, perhaps 3 to 20 characters (by replacing + with {3,20} for instance). |
Matches |
DOMAIN\ssmith | DOMAIN\a | DOMAIN\username |
Non-Matches |
ssmith | username | DOMAIN\ |
Author |
Rating:
Not yet rated.
Steven Smith
|
Title |
Test
Details
Pattern Title
|
Expression |
^[A-Za-zÀ-ÖØ-öø-ÿ '\-\.]{1,22}$ |
Description |
Should match just about any real name, either first
name or last name -- even Jill St. John.
Can't think of a name that has more than 22 characters.
My home page:
<A HREF="http://www.US-Webmasters.com/best-start-page/">http://www.US-Webmasters.com/best-start-page/</A>
|
Matches |
Jill St. John | Jørnç | Mc O'Donald-Öztürk |
Non-Matches |
abc123 | Nobody! | @#$%^& |
Author |
Rating:
Not yet rated.
W. D.
|
Title |
Test
Details
Pattern Title
|
Expression |
&(?![a-zA-Z]{2,6};|#[0-9]{3};) |
Description |
The goal of this regular expression is to replace all & (ampersand) characters by &amp; if they are not the start of HTML entities. I used
http://www.w3schools.com/html/html_entitiesref.asp as a reference. You can then use RegExp Replace method to do the work. Was helpful for me, might helpful be for you... |
Matches |
&ThisIsTooLong; | Lilo & Stich | &l; |
Non-Matches |
&lt; | &brvbar; | &#166; |
Author |
Rating:
Not yet rated.
Frederick Samson
|
Title |
Test
Details
Pattern Title
|
Expression |
^(?!\d[1]{2}|[5]{3})([2-9]\d{2})([. -]*)\d{4}$ |
Description |
Validates *usable* US telephone numbers (possibly Canadian and Caribbean Islands as well?) Numbers cannot beginning with zero, one, (any number)11, or 555. It will allow either a hyphen, space or period as a separator.
Technically (and contrary to popular belief) most 555- numbers ARE valid numbers [see http://www.nanpa.com/nas/public/form555MasterReport.do?method=display555MasterReport ] but they are unlikely to be used by normal folks. Therefore, excluding them with this regex is useful to prevent bogus/fraudulent telephone numbers in forms.
FYI, the fictitious 555- numbers used in the movies and TV are only in the range of 555-0100 through 555-0199. Not very many, huh? |
Matches |
222-2222 | 295-5000 |
Non-Matches |
555-1234 | 411-5555 | 099-9999 |
Author |
Rating:
Not yet rated.
JP Honeywell
|
Title |
Test
Details
Pattern Title
|
Expression |
^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-./])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$ |
Description |
DateTime Validator. This RE validates both dates and/or times patterns. Days in Feb. are also validated for Leap years. Dates: in dd/mm/yyyy or d/m/yy format between 1/1/1600 - 31/12/9999. Leading zeroes are optional. Date separators can be either matching dashes(-), slashes(/) or periods(.) Times: in the hh:MM:ss AM/PM 12 hour format (12:00 AM - 11:59:59 PM) or hh:MM:ss military time format (00:00:00 - 23:59:59). The 12 hour time format: 1) may have a leading zero for the hour. 2) Minutes and seconds are optional for the 12 hour format 3) AM or PM is required and case sensitive. Military time 1) must have a leading zero for all hours less than 10. 2) Minutes are manditory. 3) seconds are optional. Datetimes: combination of the above formats. A date first then a time separated by a space. ex) dd/mm/yyyy hh:MM:ss This RE is an variation of one of my other Datetime (mm/dd/yyyy) validator already in this library http://www.regexlib.com/REDetails.aspx?regexp_id=369, so the same rules for leap year apply. All 4 digit year and all two digit years except 00, which might not be a leap year. |
Matches |
31/12/2003 11:59:59 PM | 29-2-2004 | 01:45:02 |
Non-Matches |
12/31/2003 | 29.02.2005 | 13:30 PM |
Author |
Rating:
Michael Ash
|
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 |
^\d+$ |
Description |
This is derived from Steven Smith's Integer expression (http://www.regexlib.com/REDetails.aspx?regexp_id=51). The only difference is that this does not accept blanks. Written by Jason N. Gaylord. |
Matches |
2 | 50 | 0 |
Non-Matches |
-15 | 1.2 |
Author |
Rating:
Jason N. Gaylord
|
Title |
Test
Details
Pattern Title
|
Expression |
(\s*\(?0\d{4}\)?(\s*|-)\d{3}(\s*|-)\d{3}\s*)|(\s*\(?0\d{3}\)?(\s*|-)\d{3}(\s*|-)\d{4}\s*)|(\s*(7|8)(\d{7}|\d{3}(\-|\s{1})\d{4})\s*) |
Description |
another uk telephone number regex. This was adapted from another on this site http://www.regexlib.com/REDetails.aspx?regexp_id=297
I added support for hyphens and for london shorthand numbers ie. 8234-1234 72341234 Still want to be permissive where possible....Still need to sort out the all zeros, also not sure if numbers with 4 digits followed by 7 used in london 0208-234-1234 is the area of the uk where this occurs, or all areas outside of london are in format 5 digits followed by 6 digits ie. 01608 123456. If that is the case for the 4-7 pattern only 0208 or 0207 could be enforced. |
Matches |
0208 993 5689 | 0208-993-5689 | 89935689 |
Non-Matches |
1608 123 456 |
Author |
Rating:
Matt Baskey
|
Title |
Test
Details
Pattern Title
|
Expression |
(\s*\(?0\d{4}\)?(\s*|-)\d{3}(\s*|-)\d{3}\s*)|(\s*\(?0\d{3}\)?(\s*|-)\d{3}(\s*|-)\d{4}\s*)|(\s*(7|8)(\d{7}|\d{3}(\-|\s{1})\d{4})\s*) |
Description |
another uk telephone number regex. This was adapted from another on this site http://www.regexlib.com/REDetails.aspx?regexp_id=297
I added support for hyphens and for london shorthand numbers ie. 8234-1234 72341234 Still want to be permissive where possible....Still need to sort out the all zeros, also not sure if numbers with 4 digits followed by 7 used in london 0208-234-1234 is the area of the uk where this occurs, or all areas outside of london are in format 5 digits followed by 6 digits ie. 01608 123456. If that is the case for the 4-7 pattern only 0208 or 0207 could be enforced. |
Matches |
0208 993 5689 | 0208-993-5689 | 89935689 |
Non-Matches |
1608 123 456 |
Author |
Rating:
Not yet rated.
Matt Baskey
|
Displaying page
of
pages;
Items to