This post is part of a series on Mohammad Anwar’s excellent Perl Weekly Challenge, where Perl and Raku hackers submit solutions to two different challenges every week. (It’s a lot of fun, if you’re into that sort of thing.)
Personal note: I’ve had to take a break from participating in the PWC, but I’m back for this week, at least. Hopefully I’ll be able to contribute more again.
The first task this week is a sort of simple phone number validation, based on provided templates. Numbers must match the following, where
n is any decimal digit:
+nn nnnnnnnnnn (nn) nnnnnnnnnn nnnn nnnnnnnnnn
Based on the provided sample output, it seems clear that leading and trailing whitespace are ignored. Internal whitespace is also compressed, as the first provided template has two spaces after
+nn, yet the phone number
+44 1148820341 is supposed to match.
Let’s try two different methods of matching, with Perl and Raku.Continue reading “PWC 110 › Phone Number Validation”