Displaying page
of
pages;
Items to
| Title |
Test
Details
Email address (RFC 2821 mailbox)
|
| Expression |
^\s*(([/-9!#-'*+=?A-~-]+(?:\.[/-9!#-'*+=?A-~-]+)*|"(?:[^"\r\n\\]|\\.)*")@([A-Za-z][0-9A-Za-z-]*[0-9A-Za-z]?(?:\.[A-Za-z][0-9A-Za-z-]*[0-9A-Za-z]?)*|\[(?:[^\[\]\r\n\\]|\\.)*\]))\s*$ |
| Description |
This validates against the RFC 2821 (SMTP) syntax unit 'Mailbox' [equiv. to addr-spec - not address - element of RFC 2822] (the one a certain critic keeps linking to validates the RFC822 'address' element which includes support for stuff like "Group:User <address>,User <address>;", obsolete smtp routing syntax like <@host1,@host2:user@host>, etc)
There are some differences. This version does not allow line breaks for continuation lines. It also applies the stricter standards of RFC 2821 (SMTP) to the domain portion of the address.
Username may be a quoted string (but not "multiple"."quoted"."strings" - RFC 2822's grammar appears to allow this but the SMTP grammar does not). Also only one piece enclosed in [Brackets] (for IP email addresses) is allowed in the domain; that is you can't have user@[1.2.3.4].[5.6.7.8] as implied by the RFC2822 but not SMTP. Whitespace is only allowed in quoted strings. It is silently ignored at the beginning or end.
Capture group 1 is the email address, group 2 is the username, group 3 is the domain. |
| Matches |
user@example.com|user+sub@example.com|"user name"@example.com|user@[192.0.2.4] |
| Non-Matches |
no_at_sign|invalid...adjacent_dots@example.com|no quote@example.com|user@192.0.2.4 |
| Author |
Rating:
Not yet rated.
Jordan
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^\(0[1-9]{1}\)[0-9]{8}$ |
| Description |
This is used to validate an Australian telephone number with no other characters than the () being used. Validates area code being between 01 - 09. |
| Matches |
(02)12341234 | (03)12341234 | (05)12341234 |
| Non-Matches |
00 1234 1234 | 00-1234-1234 | (00)12341234 |
| Author |
Rating:
Barry Pranklin
|
| Title |
Test
Details
Parsing VB Strings (or csv qualified strings)
|
| Expression |
((?:(?:"[^"]*")|('[^\r]*)(\r\n)?)*)([\s]*[,]|$) {CHANGED TO)
(?<![\"\w\d\s])[\s]*(?:"((?:[^\"]|[\"]{2})*)"|([\w\d\s]+))[\s]*(?=[\,]|[\r\n]+|$) |
| Description |
I started out looking for a way to propertly parse delimited CSV text. Everything that I tried on my own was not doing what I wanted it to do, so I borrowed one from someone here and customized it a bit to get pretty close to what I wanted (see ORIGIONAL MESSAGE below). Ultimately though, I still needed more functionality, so I started over, and came up with this. It actually does a very good job of actually parsing columns from the CSV text. I use Regex Replace( csvText, "[$1$2]" ) to actually see the column content, but there are many other ways (obviously).
ORIGIONAL MESSAGE:
____________________________________________________
I was having trouble parsing fields from csv files due to the string qualifiers, when I came across a regex posted by Tom Svensson. It didn't quite meet my needs though because it was parsing the substrings (escaped quotes) as seperate results. This one will actually parse the entire string out, with it's escaped quote portion. None the less, thank you Tom Svensson for your help! |
| Matches |
"a""b""c", "d""e""f", JHI, 234 (pulls: a""b""c and d""e""f and JHI 234) |
| Non-Matches |
asd" |
| Author |
Rating:
Not yet rated.
David Oldfield
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^\d?\d'(\d|1[01])?.?(\d|1[01])"$ |
| Description |
This RE matches the height in feet and inches with decimals and without decimals in it |
| Matches |
5'5.5" | 2'3" | 9'10.4" |
| Non-Matches |
5 feet 5.5 inches |
| Author |
Rating:
Not yet rated.
Farida Khan
|
| Title |
Test
Details
Clean Domain Name
|
| Expression |
^http\://www.[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}/$ |
| Description |
This regex only matches clean domain names. No path after. Ends in a forward slash. Starts with http://www. It is pretty slack on the TLD requiring a 2 or 3 letter ending. This part could be tightened up if you wanted to be restrict it to specific TLDs. |
| Matches |
http://www.somedomain.co.uk/ | http://www.somedomain.com/ | http://www.dodgydomain.com.com/ |
| Non-Matches |
http://www.somedomain.co.uk/withpath.aspx | http://somedomainwithoutwww.co.uk | http://www.com/ | www.noprotocolprefix.com/ | https://www.secureprotocolprefix.com/ | http://www.notrailingslash.co.uk | HTTP://WWW.beginswithcaps.com/ |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
UK Phone Number in 4-3-4 Format
|
| Expression |
^[\d]{4}[-\s]{1}[\d]{3}[-\s]{1}[\d]{4}$ |
| Description |
Allows dashes or spaces to separate. |
| Matches |
0800 333 4444 | 0870-333-4444 | 0844 333-4444 |
| Non-Matches |
08003334444 | 0800=333=4444 | 0800 333 4444 |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
UK Phone Number in 5-3-3 Format
|
| Expression |
^[\d]{5}[-\s]{1}[\d]{3}[-\s]{1}[\d]{3}$ |
| Description |
Allows dashes or spaces to separate. |
| Matches |
08000 333 333 | 08700-333-333 | 08440 333-333 |
| Non-Matches |
08000333333 | 08000=333=333 | 08000 333 333 |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
UK Phone Number in 5-2-2-2 Format
|
| Expression |
^[\d]{5}[-\s]{1}[\d]{2}[-\s]{1}[\d]{2}[-\s]{1}[\d]{2}$ |
| Description |
Allows dashes or spaces to separate. |
| Matches |
08000 22 22 22 | 08700-22-22-22 | 08440 22-22-22 |
| Non-Matches |
08000222222 | 08000=22=22=22 | 08000 22 22 22 |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
UK Phone Number in 5-4-2 Format
|
| Expression |
^[\d]{5}[-\s]{1}[\d]{4}[-\s]{1}[\d]{2}$ |
| Description |
Allows dashes or spaces to separate. |
| Matches |
0800 4444 22 | 0870-4444-22 | 0844 4444-22 |
| Non-Matches |
0800444422 | 0800=4444=22 | 0800 4444 22 |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
UK Phone Number in 5-2-4 Format
|
| Expression |
^[\d]{5}[-\s]{1}[\d]{2}[-\s]{1}[\d]{4}$ |
| Description |
Allows dashes or spaces to separate. |
| Matches |
0800 22 4444 | 0870-22-4444 | 0844 22-4444 |
| Non-Matches |
0800224444 | 0800=22=4444 | 0800 22 4444 |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
Up to 15 digits followed by 0,1 or 2 floating points
|
| Expression |
^[0-9]{1,15}(\.([0-9]{1,2}))?$ |
| Description |
This might seem like a contrived example but it was written to answer a question on a forum. For regex newbies you can just change the numbers in {} to change the number of required digits to suit your requirements |
| Matches |
1 | 123456789012345 | 123456789012345.1 | 123456789012345.12 | 123456.12 |
| Non-Matches |
.12 | 12345.123 | 1234567890123456 |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
UK Bank Sort Code
|
| Expression |
^(\d){2}-(\d){2}-(\d){2}$ |
| Description |
Validates the format of a UK bank sort code. |
| Matches |
20-40-36 | 50-25-48 | 45-85-66 |
| Non-Matches |
204036 | 2564584 | 444-58-54 | 45/45/85 |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
UK Bank Account (8 Digits)
|
| Expression |
^(\d){8}$ |
| Description |
UK Bank account numbers are 8 digits. One bank uses 7 digits so in the validation error message you should instruct the user to prefix with a zero of their code is too short. If you want to allow the 7 digit codes as well use this regex: http://regexlib.com/REDetails.aspx?regexp_id=2707 |
| Matches |
08464524 | 45832484 | 24899544 |
| Non-Matches |
1234567 | 1 5 2226 44 | 123456789 |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
UK Bank Account (7-8 Digits)
|
| Expression |
^(\d){7,8}$ |
| Description |
UK Bank Account. One bank account issues 7 digit bank codes and you should prefix a 0 yourself after input. If you want strict validation of 8 characters use this regex: http://regexlib.com/REDetails.aspx?regexp_id=2706 |
| Matches |
1234567 | 12345678 |
| Non-Matches |
123456 | 123 4567 | 123456789 |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
No Whitespace
|
| Expression |
^[^\s]+$ |
| Description |
No whitespace is allowed in a string |
| Matches |
nowhitespace | onewordonly | anotherexample |
| Non-Matches |
two words | three words here | anything with spaces |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
UK Postcode District
|
| Expression |
([A-PR-UWYZa-pr-uwyz]([0-9]{1,2}|([A-HK-Ya-hk-y][0-9]|[A-HK-Ya-hk-y][0-9]([0-9]|[ABEHMNPRV-Yabehmnprv-y]))|[0-9][A-HJKS-UWa-hjks-uw])) |
| Description |
Matches the first part of a UK Postcode (known as a postcode district).
Case insensitive.
Doesnt match:
GIR # the postcode for the formerly Post Office-owned Girobank is GIR 0AA.
SAN # the postcode for correctly addressed letters to Father Christmas is SAN TA1 |
| Matches |
LN5 | SW1 | ln5 |
| Non-Matches |
ln5 7nq | GIR | SAN |
| Author |
Rating:
Not yet rated.
Matthew Harris
|
| Title |
Test
Details
1 to 99 in .5 increments
|
| Expression |
^[1-9]{1,2}(.5)?$ |
| Description |
This is a simple regular expression which allows 1 to 99 in .5 increments which I originally developed for a forum post |
| Matches |
1.5 | 99.5 | 35.5 | 43 | 64 | 24 |
| Non-Matches |
.5 | 100 | 0 | 0.5 | 34.3 | 24.356 | 36.55 |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
IPv4, udp/norm protocol with port
|
| Expression |
^(udp|norm)://(?:(?:25[0-5]|2[0-4]\d|[01]\d\d|\d?\d)(?(?=\.?\d)\.)){4}:\d{1,6}$ |
| Description |
Based on ip regex listed in source. Expanded to require udp:// or norm:// protocol at the start and :12345 port number at the end (1-5 digits).
Written to answer a forum question.
Current limitations - only allows lowercase protocol names and doesn't block ports that start with 0. |
| Matches |
norm://125.24.65.11:80 | udp://125.24.65.11:80 |
| Non-Matches |
125.24.65.11:80 | norm://125.24.65.11 | www.NotAnIp.com |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
Validate IP port number (1-65535)
|
| Expression |
:(6553[0-5]|655[0-2][0-9]\d|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3}) |
| Description |
This was based on the regex in the source but it was buggy so I fixed it and then optimized it.
It matches port numbers in the form of :1 to :65535
This is designed to be plugged onto the end of your favourite url regex because when I was looking for a IPv4 regex I noticed that a lot of them either didn't match the port or matched it badly (allowing the port number to start with a 0 or be higher than 65535)
This regex solves those two problems. |
| Matches |
:1 | :65535 | :2546 |
| Non-Matches |
:99999 | :0684 | :2ab23 |
| Author |
Rating:
Matthew Harris
|
| Title |
Test
Details
Validate optional IP port number (1-65535)
|
| Expression |
(:(6553[0-5]|655[0-2][0-9]\d|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3}))? |
| Description |
This is the same as my regex listed in the source except that it is wrapped in (regex)? which makes it optional. The intended use for this regex is to be combined with buggy url/ip regex's to strengthen the port matching. It matches port numbers in the form of :1 to :65535 and also allows no port to be entered. I noticed that a lot of url/ip regexs either didn't match the port or matched it badly (allowing the port number to start with a 0 or be higher than 65535) This regex solves those two problems. |
| Matches |
:1 | :65535 | :2546 | no port entered |
| Non-Matches |
:99999 | :0684 | :2ab23 |
| Author |
Rating:
Matthew Harris
|
Displaying page
of
pages;
Items to