Displaying page
of
pages;
Items to
| Title |
Test
Details
Pattern Title
|
| Expression |
^(Function|Sub)(\s+[\w]+)\([^\(\)]*\) |
| Description |
Updated, changed [\w]* to [\w]+ because pattern should not match Sub (), there would be no function name which would be incorrect.
Will extract function declarations from ASP or also VB I assume. Will even capture declarations that break across new lines or ones that use the underscore(line continuation character) in Microsoft's VB, VBA, ASP, etc. Had to put this together to document some code on a project and didn't see anything like it on the web. I hope it helps out anyone else who has to re-engineer ASP or VB code. |
| Matches |
Function MyFunc(Arg1, Arg2, Arg3, Arg4) |
| Non-Matches |
'This is a comment for MyFunc(Arg1,Arg2,Arg3) and this regexp wouldn't work. |
| Author |
Rating:
James Fal
|
| Title |
Test
Details
Validate numbers with commas
|
| Expression |
^(\d{1,3},)?(\d{3},)+\d{3}(\.\d*)?$|^(\d*)(\.\d*)?$ |
| Description |
Validates numbers with commas. |
| Matches |
12 - 12.45 - 12,456,456.45 - |
| Non-Matches |
123,455.45. - 45,4564,12 - ,12,456 |
| Author |
Rating:
Not yet rated.
Luis Fleitas
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(\..+)?$)[^\x00-\x1f\\?*<>:\;|\"/]+$ |
| Description |
Additional checks for <> and " characters |
| Matches |
abc |
| Non-Matches |
PRN |
| Author |
Rating:
Rahul Pandit
|
| Title |
Test
Details
c++ function finder
|
| Expression |
^.*[_A-Za-z0-9]+[\t ]+[\*&]?[\t ]*[_A-Za-z0-9](::)?[_A-Za-z0-9:]+[\t ]*\(( *[ \[\]\*&A-Za-z0-9_]+ *,? *)*\).*$ |
| Description |
This (while not perfect) locates c++ function declarations. Useful for working with large source files |
| Matches |
void helloworld(), FILE *MyClass::getFile(), int getFibbNum (int place) |
| Non-Matches |
getFibbNum(3), int MyNum;, for (int x=1 ... ) |
| Author |
Rating:
Not yet rated.
B Horrocks
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^((67\d{2})|(4\d{3})|(5[1-5]\d{2})|(6011))-?\s?\d{4}-?\s?\d{4}-?\s?\d{4}|3[4,7]\d{13}$ |
| Description |
Credit Card Matching - Matches Switch, Solo, Visa, MasterCard and Discover. Matches length and valid prefix. Accepts input optional spaces and dashes between number groups |
| Matches |
5154-1234-1234-1342 | 4444333322221111 | 6767 1111 1111 1111 |
| Non-Matches |
1234123412341234 | 1111111 | 987654321 |
| Author |
Rating:
hazel ryan
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^((67\d{2})|(4\d{3})|(5[1-5]\d{2})|(6011))(-?\s?\d{4}){3}|(3[4,7])\d{2}-?\s?\d{6}-?\s?\d{5}$ |
| Description |
Credit Card Validation. Matches Switch/Solo, Visa, MasterCard and Discover in 4-4-4-4/4 4 4 4/4444 format and Amex in 4-6-5/4 6 5/465 format.
Includes checks for prefixes, (67 for switch/solo, 4 for visa, 51-55 for MasterCard, 37/34 for Amex and 6011 for Discover.
Matches all major UK debit and credit cards with spaces dashes or as a continous number |
| Matches |
4234 1234 1234 1234 | 5434123412341234 | 3712 123456 12345 |
| Non-Matches |
1234123412341234 | 1111111 | 987654321 |
| Author |
Rating:
hazel ryan
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^[a-z\.]*\s?([a-z\-\']+\s)+[a-z\-\']+$ |
| Description |
Matches Names - written for credit card matching.
Optional Prefix that can contain a fullstop, one or more forenames that can contain hyphens and apostrophes followed by a surname that can contain hyphens and apostrophes |
| Matches |
Miss H Ryan | Miss Ryan | Miss Hazel Joanne Ryan |
| Non-Matches |
Hazel | Hazel Ryan |
| Author |
Rating:
hazel ryan
|
| Title |
Test
Details
Pattern Title
|
| Expression |
((\s*([^,{]+)\s*,?\s*)*?){((\s*([^:]+)\s*:\s*([^;]+?)\s*;\s*)*?)} |
| Description |
will break out a valid CSS stylesheet into it's components. Groups on each style, all selectors, each selector within a comma delimited list of selectors, all properties, each property set, each property and each value. In other words, it breaks it all down for you :)
The only two problems I'm having with it:
A) it is ignorant of comment blocks. so if you have styles within a /* */ block, it'll pick those up.
B) the first style following a comment block is not parsed correctly (it incorrectly includes the comment as a selector
best thing to do would be to use another regexp to remove all comments before processing with this one |
| Matches |
div#main { position:relative; width:809px; margin-left:auto; margin-right:auto; padding:0; } |
| Non-Matches |
----- |
| Author |
Rating:
Nick Franceschina
|
| 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
Pattern Title
|
| Expression |
(?:/\*[\w\W]*?\*/|//[^\n]*?$|\#[^\n]*?$) |
| Description |
Return all comment lines (starts with //) and regions (serounded by /* */) as well as compiler arguments (#) in C# code |
| Matches |
// some comment | #region myRegion | /* other comment */ |
| Non-Matches |
for(int i = 0; i < 10; i++) | [XmlAttribute("somthing_else") | String name = "MyNa |
| Author |
Rating:
Ittayy Ophir
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(^|\s|\()((([1-9]){1}|([0][1-9]){1}|([1][012]){1}){1}[\/-]((2[0-9]){1}|(3[01]){1}|([01][1-9]){1}|([1-9]){1}){1}[\/-](((19|20)([0-9][0-9]){1}|([0-9][0-9]){1})){1}(([\s|\)|:])|(^|\s|\()((([0-9]){1}|([0][1-9]){1}|([1][012]){1}){1}[\/-](([11-31]){1}|([01][1-9]){1}|([1-9]){1}){1}[\/-](((19|20)([0-9][0-9]){1}|([0-9][0-9]){1})){1}(([\s|\)|:|$|\>])){1}){1}){1}){1} |
| Description |
Will match the following date formats: Preceded by a Space, Left-parentheses, or at the beginning of a line. Followed by a Space, Right-parentheses, or Colon(:), word boundary or End of line. Can have / or - as separator. Accepts 2 digit year 00-99 or 4 digit years 1900-2099 (can modify to accept any range) |
| Matches |
01/01/2001 | 01-01-2001: | (1-1-01) |
| Non-Matches |
13/1/2001 | 1-32-2001 | 1-1-1801 |
| Author |
Rating:
David Good
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(\w(\s)?)+ |
| Description |
Used to verify that the string consists of only A-z, 0 - 9 and underscore. Several words allowed, only one space between them. No spaces up front. Hey, I know it's easy, but it was not in the library! Plus, the test option here is not working well all the time. |
| Matches |
Test | TesT | tesT9 _test9 |
| Non-Matches |
\\\ |
| Author |
Rating:
Not yet rated.
Alsu Fifty
|
| Title |
Test
Details
Real Float Number
|
| Expression |
[+-]?+(?>\d++\.?+\d*+|\d*+\.?+\d++) |
| Description |
This regex is designed to fail fast (using possessive quantifiers) while still matching a floating decimal number all the time. Won't match scientific notation or fractions. Can be combined with other patterns.
Note: This site's tester does not support them.
If your language does not support possessive quantifiers try the following:
(?>[+-]?)(?>(?>\d+)(?>\.?)(?>\d*)|(?>\d*)(?>\.?)(?>\d+)) |
| Matches |
+7 | -7.7 | .7 | 7. | etc |
| Non-Matches |
1/7 | 7e10 |
| Author |
Rating:
Trinithis
|
| Title |
Test
Details
Split camelCase word
|
| Expression |
(?<!^)(?=[A-Z]) |
| Description |
Used with the Regex.Split() function in .NET, this will easily split a camelCase word on the upper case letters, while not dropping any characters. (That makes it different from most split() functions -- it does not drop any characters.) More details in my blog - http://blogs.lotterypost.com/speednet/2007/08/simple-function-to-split-camelcase-words.htm |
| Matches |
camelCase |
| Non-Matches |
<empty string> |
| Author |
Rating:
Speednet
|
| Title |
Test
Details
SQL Server 2005 datetime validation
|
| Expression |
^((((((((jan(uary)?)|(mar(ch)?)|(may)|(july?)|(aug(ust)?)|(oct(ober)?)|(dec(ember)?)) ((3[01])|29))|(((apr(il)?)|(june?)|(sep(tember)?)|(nov(ember)?)) ((30)|(29)))|(((jan(uary)?)|(feb(ruary)?|(mar(ch)?)|(apr(il)?)|(may)|(june?)|(july?)|(aug(ust)?)|(sep(tember)?)|(oct(ober)?)|(nov(ember)?)|(dec(ember)?))) (2[0-8]|(1\d)|(0?[1-9])))),? )|(((((1[02])|(0?[13578]))[\.\-/]((3[01])|29))|(((11)|(0?[469]))[\.\-/]((30)|(29)))|(((1[0-2])|(0?[1-9]))[\.\-/](2[0-8]|(1\d)|(0?[1-9]))))[\.\-/])|(((((3[01])|29)[ \-\./]((jan(uary)?)|(mar(ch)?)|(may)|(july?)|(aug(ust)?)|(oct(ober)?)|(dec(ember)?)))|(((30)|(29))[ \.\-/]((apr(il)?)|(june?)|(sep(tember)?)|(nov(ember)?)))|((2[0-8]|(1\d)|(0?[1-9]))[ \.\-/]((jan(uary)?)|(feb(ruary)?|(mar(ch)?)|(apr(il)?)|(may)|(june?)|(july?)|(aug(ust)?)|(sep(tember)?)|(oct(ober)?)|(nov(ember)?)|(dec(ember)?)))))[ \-\./])|((((3[01])|29)((jan)|(mar)|(may)|(jul)|(aug)|(oct)|(dec)))|(((30)|(29))((apr)|(jun)|(sep)|(nov)))|((2[0-8]|(1\d)|(0[1-9]))((jan)|(feb)|(mar)|(apr)|(may)|(jun)|(jul)|(aug)|(sep)|(oct)|(nov)|(dec)))))(((175[3-9])|(17[6-9]\d)|(1[89]\d{2})|[2-9]\d{3})|\d{2}))|((((175[3-9])|(17[6-9]\d)|(1[89]\d{2})|[2-9]\d{3})|\d{2})((((1[02])|(0[13578]))((3[01])|29))|(((11)|(0[469]))((30)|(29)))|(((1[0-2])|(0[1-9]))(2[0-8]|(1\d)|(0[1-9])))))|(((29feb)|(29[ \.\-/]feb(ruary)?[ \.\-/])|(feb(ruary)? 29,? ?)|(0?2[\.\-/]29[\.\-/]))((((([2468][048])|([3579][26]))00)|(17((56)|([68][048])|([79][26])))|(((1[89])|([2-9]\d))(([2468][048])|([13579][26])|(0[48]))))|(([02468][048])|([13579][26]))))|(((((([2468][048])|([3579][26]))00)|(17((56)|([68][048])|([79][26])))|(((1[89])|([2-9]\d))(([2468][048])|([13579][26])|(0[48]))))|(([02468][048])|([13579][26])))(0229)))$ |
| Description |
This expression validates most legal dates for a SQL Server 2005 datetime format. It includes checking for leap years. (Written for a default U.S. install, not sure what results would be on versions for different regions)
For double digit dates, 00 is considered to be the year 2000, so leap years will be valid.
This will handle dates in the following formats
yymmdd
yyyymmdd
m/d/yy
mm/dd/yy
m/d/yyyy
mm/dd/yyyy
m-d-yy
mm-dd-yy
m-d-yyyy
mm-dd-yyyy
m.d.yy
mm.dd.yy
m.d.yyyy
mm.dd.yyyy
mmmm dd yy
mmmm dd yyyy
mmmm dd, yy
mmmm dd, yyyy
mmmm d yy
mmmm d yyyy
mmmm d, yy
mmmm d, yyyy
d mmmm yy
d mmmm yyyy
dd mmmm yy
dd mmmm yyyy
d-mmmm-yy
d-mmmm-yyyy
dd-mmmm-yy
dd-mmmm-yyyy
d.mmmm.yy
d.mmmm.yyyy
dd.mmmm.yy
dd.mmmm.yyyy
d/mmmm/yy
d/mmmm/yyyy
dd/mmmm/yy
dd/mmmm/yyyy
mmm dd yy
mmm dd yyyy
mmm dd, yy
mmm dd, yyyy
mmm d yy
mmm d yyyy
mmm d, yy
mmm d, yyyy
dd mmm yy
dd mmm yyyy
d mmm yy
d mmm yyyy
ddmmmyy
ddmmmyyyy
dd-mmm-yy
dd-mmm-yyyy
d-mmm-yy
d-mmm-yyyy
dd.mmm.yy
dd.mmm.yyyy
d.mmm.yy
d.mmm.yyyy
dd/mmm/yy
dd/mmm/yyyy
d/mmm/yy
d/mmm/yyyy
Note: This will also handle mixing and matching of separator characters. for example:
'1/1.2000',
It would appear that this is valid in SQL Server 2005.
This is written to work for ECMA script (include the ignore case parameter i), but should also work in .Net.
I have tested this in firefox 2.0 (Blazing Fast) and IE 7.0 and both seem to work just fine. I have not tested it in .Net.
It's pretty large and I have not attempted to optimize it. Feel free to optimize it any way you like. |
| Matches |
20000229 | 000229 | 12/31/9999 | Dec 02, 99 | 30MAR1753 | Feb 29, 1756 | 1.1.2008 |
| Non-Matches |
21000229 | 990229 | 12/32/9999 | Xxx 02, 99 | 30MAR1752 | Feb 29, 1752 | 1.0.2008 |
| Author |
Rating:
Christopher Strolia-Davis
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^((Bob)|(John)|(Mary)).*$(?<!White) |
| Description |
"Starts with but does not end with."
I needed a pattern to require certain first (and optional middle) names, but to fail for certain last names. So if Bob, John, and Mary are acceptable first names but the White's are always rejected then...
|
| Matches |
Bob Jones | John Smith | Mary Jane Smith |
| Non-Matches |
Bob White | Mary Doe White | Gina Smith |
| Author |
Rating:
Eli Robillard
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^[0-9]{4}\s{0,2}[a-zA-z]{2}$ |
| Description |
Dutch postalcode expression. 4 digits followed by max. two spaces end ending on two letters. |
| Matches |
4006 AB | 4006ab | 4006 AB |
| Non-Matches |
4006.ab | 4006_ab | 4006/ab |
| Author |
Rating:
martijn db
|
| Title |
Test
Details
RFC2822 Compliant Email Address
|
| Expression |
^(?i:(?<local_part>[a-z0-9!#$%^&*{}'`+=-_|/?]+(?:\.[a-z0-9!#$%^&*{}'`+=-_|/?]+)*)@(?<labels>[a-z0-9]+\z?.*[a-z0-9-_]+)*(?<tld>\.[a-z0-9]{2,}))$ |
| Description |
RFC2822 compliant. Includes all special characters, except for allowance of quoted local-part. Also disallows '.' (period) to be at the front or end of local-part, or occurr more than once consecutively. It does allow for optional infinite number of sub-domains.
The following standards are not enforced, due to RegExp limitations (unable to check for group string length):
As per RFC2821 the local-part may have a maximum length of 64 characters, while the domain name may have a maximum length of 255 characters.
Each domain label must be between 1 and 63 characters long, while the total length of the domain name may not exceed 255 characters. |
| Matches |
my.sub.test.server@sub.host.server.uk.co |
| Non-Matches |
.stubs@com|.me@server.com|my..name@server.com |
| Author |
Rating:
Mike Bronner
|
| Title |
Test
Details
RFC Compliant URI
|
| Expression |
^([A-Za-z0-9]+[A-Za-z0-9-_]*\.)*(([A-Za-z0-9]+[A-Za-z0-9-_]*){3,}\.)+([A-Za-z0-9]{2,4}\.?)+)$ |
| Description |
RFC compliant. Disallows '.' (period) to be at the front or end, or occurr more than once consecutively. It does allow for optional infinite number of sub-domains. However, the total length of the URI has not been enforced: each label must be between 1 and 63 characters long, while the total length of the domain name may not exceed 255 characters.
Note that this RegEx does not check the validity of the protocol. |
| Matches |
mine.com|me.mine.com |
| Non-Matches |
com|me..com|me.com|me..mine.com|.mine.com |
| Author |
Rating:
Not yet rated.
Mike Bronner
|
| Title |
Test
Details
Integer with 1000s Separator
|
| Expression |
^[1-9]{1}[0-9]{0,2}([\.\,]?[0-9]{3})*$ |
| Description |
Matches whole numbers with the two most common thousands-separators (comma and period). Will not handle decimals. |
| Matches |
1,000|1.000|1|10|100|1000 |
| Non-Matches |
1,00|1,0|1,,000|.1|10. |
| Author |
Rating:
Not yet rated.
Mike Bronner
|
Displaying page
of
pages;
Items to