Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phone number formatter to utilise regular expressions #19

Open
silaselisha opened this issue Mar 11, 2024 · 1 comment
Open

phone number formatter to utilise regular expressions #19

silaselisha opened this issue Mar 11, 2024 · 1 comment

Comments

@silaselisha
Copy link

if len(phone_number) < 9: raise IllegalPhoneNumberException('Phone number too short')
I believe the utility function for formatting phone numbers should be implemented using a regular expression, unless there was a specific reason not to do so

@Naftali-B
Copy link

Using regular expressions can be computationally more expensive (big O-notation) than simple string manipulation methods like checking the length and for non-alphanumeric characters.

When you're dealing with a specific and relatively simple phone number format, such as those commonly used in a particular region, using regular expressions might be unnecessary overhead. In such cases, directly checking the length and presence of non-alphanumeric characters can be more efficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants