File Coverage

blib/lib/Regexp/Constant.pm
Criterion Covered Total %
statement 258 258 100.0
branch n/a
condition n/a
subroutine 86 86 100.0
pod n/a
total 344 344 100.0


line stmt bran cond sub pod time code
1              
2             package Regexp::Constant;
3              
4             # $Id: Constant.pm,v 1.22 2004/10/25 16:34:35 root Exp $
5              
6 1     1   23269 use 5.008;
  1         5  
  1         48  
7 1     1   6 use strict;
  1         3  
  1         43  
8 1     1   7 use warnings;
  1         7  
  1         180  
9              
10             require Exporter;
11              
12             our @ISA = qw(Exporter);
13              
14             our %EXPORT_TAGS = ( 'all' => [ qw(
15              
16             ) ] );
17              
18             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
19              
20             our @EXPORT = qw(
21              
22             );
23              
24             our $VERSION = '1.22';
25              
26             # FOR INTERNAL USE ONLY
27 1     1   6 use constant REGEX_DEL1 => q{\b(};
  1         1  
  1         100  
28 1     1   5 use constant REGEX_DEL2 => q{)\b};
  1         1  
  1         54  
29              
30             # NUMERIC
31 1     1   5 use constant REGEX_SIGNED => q{\b(\-\+])\b};
  1         2  
  1         48  
32 1     1   5 use constant REGEX_BINARY => q{\b([01]+)\b};
  1         2  
  1         49  
33 1     1   5 use constant REGEX_DECIMAL => q{\b(\d+)\b};
  1         1  
  1         48  
34 1     1   4 use constant REGEX_FLOAT => q{\b(\d*\.\d+)\b};
  1         2  
  1         41  
35 1     1   13 use constant REGEX_HEX => q{\b([\da-fA-F]+)\b};
  1         2  
  1         50  
36 1     1   5 use constant REGEX_OCTAL => q{\b([0-7]+)\b};
  1         1  
  1         41  
37 1     1   5 use constant REGEX_OCTET => q{\b([0-9a-zA-Z]{2})\b};
  1         7  
  1         47  
38              
39 1     1   5 use constant REGEX_COMMA_DELIMITED_NUMBER => q{\b([0-9])+([,]([0-9])+)*\b};
  1         2  
  1         59  
40              
41             # MYSQL DATA TYPES
42 1     1   10 use constant REGEX_TINYINT => q{\b[012](\d1,2)\b};
  1         1  
  1         64  
43 1     1   5 use constant REGEX_TINYINT_SIGNED => REGEX_SIGNED . q{\b[01](\d1,2)\b};
  1         2  
  1         44  
44 1     1   4 use constant REGEX_SMALLINT => q{\b[0-6](\d1,4)\b};
  1         2  
  1         60  
45 1     1   5 use constant REGEX_SMALLINT_SIGNED => REGEX_SIGNED . q{\b[0-3](\d1,4)\b};
  1         1  
  1         90  
46 1     1   5 use constant REGEX_MEDIUMINT => q{\b[01](\d1,7)\b};
  1         1  
  1         106  
47 1     1   6 use constant REGEX_MEDIUMINT_SIGNED => REGEX_SIGNED . q{\b[0-8](\d1,6)\b};
  1         1  
  1         51  
48 1     1   6 use constant REGEX_INT => q{\b[0-4](\d1,9)\b};
  1         2  
  1         55  
49 1     1   6 use constant REGEX_INT_SIGNED => REGEX_SIGNED . q{\b[0-2](\d1,9)\b};
  1         2  
  1         48  
50 1     1   6 use constant REGEX_BIGINT => q{\b[01](\d1,19)\b};
  1         2  
  1         68  
51 1     1   5 use constant REGEX_BIGINT_SIGNED => REGEX_SIGNED . q{\b[0-9](\d1,18)\b};
  1         1  
  1         96  
52              
53              
54             # signed, exponents 1e4, percent, fraction "1 1/2"
55              
56             # currency
57              
58              
59             # IP
60 1     1   5 use constant REGEX_MAC_ADDRESS => join (":", REGEX_OCTET, REGEX_OCTET, REGEX_OCTET, REGEX_OCTET, REGEX_OCTET, REGEX_OCTET);
  1         10  
  1         55  
61              
62 1     1   4 use constant REGEX_IP_CLASS_A => q{\b([01]?\d?\d|2[0-4]\d|25[0-5])\b};
  1         2  
  1         83  
63 1     1   5 use constant REGEX_IP_CLASS_B => q{\b(} . join (".", REGEX_IP_CLASS_A, REGEX_IP_CLASS_A) . REGEX_DEL2;
  1         2  
  1         87  
64 1     1   5 use constant REGEX_IP_CLASS_C => q{\b(} . join (".", REGEX_IP_CLASS_B, REGEX_IP_CLASS_A) . REGEX_DEL2;
  1         2  
  1         87  
65 1     1   5 use constant REGEX_IP_ADDRESS => q{\b(} . join (".", REGEX_IP_CLASS_C, REGEX_IP_CLASS_A) . REGEX_DEL2;
  1         2  
  1         60  
66              
67 1     1   4 use constant REGEX_DOMAIN_NAME => qw{\b(([\w\-]+)+\.\w+)\b};
  1         2  
  1         57  
68 1     1   4 use constant REGEX_EMAIL_ADDRESS => q{([\w\-]+)\@} . REGEX_DOMAIN_NAME;
  1         2  
  1         52  
69              
70             # TIME
71 1     1   5 use constant REGEX_HOUR => q{\b([ 01]\d|2[0-3])\b};
  1         1  
  1         42  
72 1     1   5 use constant REGEX_MINUTE => q{\b([0-5]\d)\b};
  1         9  
  1         57  
73 1     1   5 use constant REGEX_SECOND => q{\b([0-5]\d)\b};
  1         2  
  1         86  
74 1     1   5 use constant REGEX_TIME => q{\b(} . join(":", REGEX_HOUR, REGEX_MINUTE, REGEX_SECOND) . REGEX_DEL2;
  1         1  
  1         58  
75              
76 1     1   5 use constant REGEX_GMT_OFFSET => q{([\+\-]\d{4})};
  1         19  
  1         45  
77              
78             # TIMEZONE
79 1     1   6 use constant REGEX_TIMEZONE => q{\b([A-Z]{3})\b};
  1         1  
  1         43  
80              
81             # DAY
82 1     1   5 use constant REGEX_DAY => q{(\d{1,2})};
  1         2  
  1         48  
83 1     1   5 use constant REGEX_WEEKDAY_ABBREVIATED => q{\b(Sun|Mon|Tue|Wed|Thu|Fri|Sat)\b};
  1         2  
  1         47  
84 1     1   5 use constant REGEX_WEEKDAY_NAME => q{\b(Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)\b};
  1         2  
  1         82  
85 1     1   6 use constant REGEX_WEEKDAY => q{\b(} . join ("|", REGEX_WEEKDAY_ABBREVIATED, REGEX_WEEKDAY_NAME) . REGEX_DEL2;
  1         1  
  1         54  
86              
87             # MONTH
88 1     1   4 use constant REGEX_MONTH_NUMERIC => q{\b(\d|[ 0]\d|[1][012])\b};
  1         1  
  1         46  
89 1     1   4 use constant REGEX_MONTH_NAME_ABBREVIATED => q{\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\b};
  1         2  
  1         53  
90 1     1   5 use constant REGEX_MONTH_NAME => q{\b(January|February|March|April|May|June|July|August|September|October|November|December)\b};
  1         2  
  1         90  
91 1     1   6 use constant REGEX_MONTH => q{\b(} . join("|", REGEX_MONTH_NUMERIC, REGEX_MONTH_NAME_ABBREVIATED, REGEX_MONTH_NAME) . REGEX_DEL2;
  1         1  
  1         47  
92              
93             # DATE
94 1     1   11 use constant REGEX_YEAR => q{\b(\d{2}|\d{4})\b};
  1         11  
  1         72  
95 1     1   5 use constant REGEX_CLF_DATE => join("[\/-]", REGEX_DAY, REGEX_MONTH, REGEX_YEAR);
  1         2  
  1         74  
96 1     1   5 use constant REGEX_MYSQL_DATE => join ("-", REGEX_YEAR, REGEX_MONTH_NUMERIC, REGEX_DAY);
  1         1  
  1         103  
97              
98             # DATE TIME
99 1     1   5 use constant REGEX_CLF_DATETIME => REGEX_DEL1 . REGEX_CLF_DATE . ":" . REGEX_TIME . REGEX_DEL2;
  1         1  
  1         81  
100 1     1   5 use constant REGEX_MYSQL_DATETIME => REGEX_DEL1 . REGEX_MYSQL_DATE . " " . REGEX_TIME . REGEX_DEL2;
  1         1  
  1         93  
101 1     1   5 use constant REGEX_SHELL_DATE => REGEX_DEL1 . join (q{\s}, REGEX_WEEKDAY, REGEX_MONTH, REGEX_DAY, REGEX_TIME, REGEX_TIMEZONE, REGEX_YEAR) . REGEX_DEL2;
  1         1  
  1         53  
102              
103              
104              
105 1     1   4 use constant REGEX_ROMAN_NUMERAL => q{\b(?i:M{0,3}((C[DM])|(D?C{0,3}))?L?(X((X{1,2})|L|C)?)?((I((I{1,2})|V|X|L)?)|(V?I{0,3}))?)\b};
  1         7  
  1         43  
106              
107              
108              
109             # PHONE
110             # TODO: "(303) 622-2173", "1-800-CALL-FIG"
111 1     1   5 use constant REGEX_AREA_CODE => q{((\(\d{3}\))|(\d{3}))};
  1         1  
  1         34  
112 1     1   5 use constant REGEX_PHONE_EXCHANGE => q{(\d{3})};
  1         1  
  1         42  
113 1     1   4 use constant REGEX_PHONE_EXTENSION => q{(\d{4})};
  1         2  
  1         85  
114 1     1   5 use constant REGEX_PHONE => REGEX_DEL1 . join(q{[ \-\.]?}, REGEX_AREA_CODE, REGEX_PHONE_EXCHANGE, REGEX_PHONE_EXTENSION) . REGEX_DEL2;
  1         1  
  1         46  
115              
116             # HTML
117 1     1   5 use constant REGEX_HTML_SIMPLE => q{\b(<[^>]+>)\b};
  1         1  
  1         37  
118              
119 1     1   4 use constant REGEX_REQUEST_METHOD => q{(\S+)};
  1         2  
  1         55  
120              
121 1     1   4 use constant REGEX_REQUEST_OBJECT => q{([^ ]+)};
  1         3  
  1         38  
122 1     1   4 use constant REGEX_URI => q{};
  1         1  
  1         37  
123              
124 1     1   4 use constant REGEX_PROTOCOL => q{(\w+\/[\d\.]+)};
  1         1  
  1         38  
125 1     1   4 use constant REGEX_RESPONSE_CODE => q{(\d+|\-)};
  1         2  
  1         44  
126 1     1   4 use constant REGEX_CONTENT_LENGTH => q{(\d+|\-)};
  1         1  
  1         45  
127 1     1   4 use constant REGEX_HTTP_REFERER => q{([^"]+)};
  1         1  
  1         39  
128 1     1   5 use constant REGEX_HTTP_USER_AGENT => q{([^"]+)};
  1         1  
  1         38  
129 1     1   4 use constant REGEX_COOKIE => q{([^"]+)};
  1         1  
  1         39  
130              
131 1     1   4 use constant REGEX_STATE => q{\b(Alabama|Alaska|American Samoa|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|District of Columbia|Federated States of Micronesia|Florida|Georgia|Guam|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Marshall Islands|Maryland|Massachusetts|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Northern Mariana Islands|Ohio|Oklahoma|Oregon|palau|Pennsylvania|Puerto Rico|Rhode Island|South Carolina|South Dakota|Tennessee|Texas|Utah|Vermont|Virgin Islands|Virginia|Washington|West Virginia|Wisconsin|Wyoming)\b};
  1         1  
  1         44  
132 1     1   4 use constant REGEX_STATE_ABBREVIATION => q{\b(A[AELKPSZR]|C[AOT]|D[EC]|F[NL]|G[AU]|HI|I[DLNA]|K[SY]|LA|M[EHDAINSOT]|N[EVHJMYCD]|MP|O[HKR]|P[WR]|RI|S[CD]|T[NX]|UT|V[TIA]|W[AVIY])\b};
  1         1  
  1         33  
133              
134 1     1   4 use constant REGEX_ZIP_CODE => q{\b(\d{5})\b};
  1         1  
  1         54  
135 1     1   5 use constant REGEX_ZIP_CODE_PLUS_FOUR => REGEX_ZIP_CODE . q{\-\b(\d{4})\b};
  1         2  
  1         49  
136              
137 1     1   21 use constant REGEX_REPEATED_WORD => q{\b(\w+)\s+\1\b};
  1         2  
  1         45  
138              
139 1     1   6 use constant REGEX_WINDOWS_FILENAME => q{(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.([0-9a-zA-Z]+)};
  1         1  
  1         47  
140              
141             # WORD / TEXT
142 1     1   6 use constant REGEX_NUMBER => q{\b(\d+)\b};
  1         1  
  1         67  
143 1     1   5 use constant REGEX_WORD_UNCAPITALIZED => q{\b([a-z]+)\b};
  1         2  
  1         48  
144 1     1   6 use constant REGEX_WORD_CAPITALIZED => q{\b([A-Z][a-z]*)\b};
  1         1  
  1         67  
145              
146             # NAME [T.F. Johnson], [John O'Neil], [Mary-Kate Johnson]
147              
148 1     1   5 use constant REGEX_MD5 => q{\b([a-z][0-9]{32})\b};
  1         2  
  1         49  
149 1     1   6 use constant REGEX_GUID => q{\b([0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12})\b};
  1         1  
  1         57  
150              
151 1     1   5 use constant REGEX_ISBN => q{\b((ISBN *)?\d[ \-]?\d{5}[ \-]?\d{3}[ \-]?[\dxX])\b};
  1         1  
  1         56  
152 1     1   77 use constant REGEX_SSN => q{\b(\d{3}[ \-]?\d{2}[ \-]?\d{4})\b};
  1         3  
  1         125  
153              
154             # CREDIT CARD
155 1     1   6 use constant REGEX_VISA => REGEX_DEL1 . join ("([ \-]|)", q{4\d{3}}, q{\d{4}}, q{\d{4}}, q{\d{4}}) . REGEX_DEL2;
  1         1  
  1         101  
156 1     1   5 use constant REGEX_MASTERCARD => REGEX_DEL1 . join ("([ \-]|)", q{5\d{3}}, q{\d{4}}, q{\d{4}}, q{\d{4}}) . REGEX_DEL2;
  1         2  
  1         99  
157 1     1   6 use constant REGEX_DISCOVER => REGEX_DEL1 . join ("([ \-]|)", "6011", q{\d{4}}, q{\d{4}}, q{\d{4}}) . REGEX_DEL2;
  1         2  
  1         112  
158 1     1   4 use constant REGEX_DINERS_CLUB => REGEX_DEL1 . join ("([ \-]|)", q{(3[68]\d{2}|30[0-5]\d)}, q{\d{4}}, q{\d{4}}, q{\d{4}}) . REGEX_DEL2;
  1         2  
  1         48  
159 1     1   4 use constant REGEX_AMERICAN_EXPRESS => q{\b(3[47]\d{13})\b};
  1         2  
  1         87  
160              
161 1     1   4 use constant REGEX_CREDIT_CARD => REGEX_DEL1 . join ("|", REGEX_VISA, REGEX_MASTERCARD, REGEX_DISCOVER, REGEX_DINERS_CLUB, REGEX_AMERICAN_EXPRESS) . REGEX_DEL2;
  1         2  
  1         77  
162 1     1   4 use constant REGEX_CREDIT_CARD_EXPIRATION => REGEX_DEL1 . join("[ \-\/]", REGEX_MONTH_NUMERIC, REGEX_YEAR) . REGEX_DEL2;
  1         1  
  1         44  
163 1     1   4 use constant REGEX_CREDIT_CARD_VALIDATION => q{\b(\d{3})\b};
  1         2  
  1         58  
164              
165             # comma delimited list , ,"", etc ,(?!(?<=(?:^|,)\s*"(?:[^"]|""|\\")*,)(?:[^"]|""|\\")*"\s*(?:,|$))
166              
167              
168             1;
169             __END__