The checkPhoneNumber method should check whether the phoneNumber argument is a valid phone number. Verification criteria: 1) if the number starts with '+', then it must contain 12 digits; 2) if the number starts with a digit or opening parenthesis, then it must contain 10 digits.
Phone number verification
You must be signed in to leave a comment
9 August 2021, 17:54
I downloaded the correct regex solution after passing the task by writing methods for partial checks and I wonder - are complicated regex like the one in the solution actually used in production code? It seems pretty unreadable to me given that you should usually be able to read from the code what it does. I suppose you could document it thoroughly, but just cutting up the whole thing into smaller tasks seems like the more logical solution to me.
21 March, 21:08
I have similiar thoughts to you, but regex is new to us, and maybe after some time it'll be more readeable. I did this task using only one more complicated pattern, and it was -->:D