diff options
| -rw-r--r-- | challenge-110/james-smith/perl/ch-1.pl | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-110/james-smith/perl/ch-1.pl b/challenge-110/james-smith/perl/ch-1.pl index f47ec05169..5435cde1b1 100644 --- a/challenge-110/james-smith/perl/ch-1.pl +++ b/challenge-110/james-smith/perl/ch-1.pl @@ -9,6 +9,21 @@ use Test::More; print grep { is_valid_phone_number($_) } <>; sub is_valid_phone_number { + return m{\A # Start of line + \s* # Some white-space ? + (?: # Prefix - one of: + [+]\d+ | # +{digits} + 00\d+ | # 00{digits} + [(]\d+[)] # ({digits}) + ) + \s+ # Some white-space + \d+ # String of numbers + \s* # Some white-space ? + \Z # End of line + }x; +} + +sub is_valid_phone_number_compact { return m{\A\s*(?:[+]\d+|00\d+|[(]\d+[)])\s+\d+\s*\Z}; } |
