Answer the question
In order to leave comments, you need to log in
How to fix regular expression for phone number search?
I'm not very good with regular expressions. Found this on google
'^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$'
Answer the question
In order to leave comments, you need to log in
Use the libphonenumber library , it is adapted for many
C# programming languages: https://github.com/twcclegg/libphonenumber-csharp
Go: https://github.com/nyaruka/phonenumbers
Objective-c: https://github.com/ iziz/libPhoneNumber-iOS
PHP: https://github.com/giggsey/libphonenumber-for-php
PostgreSQL in-database types: https://github.com/blm768/pg-libphonenumber
Python: https://github.com /daviddrysdale/python-phonenumbers
Ruby: https://github.com/mobi/telephone_number
Rust: https://github.com/1aim/rust-phonenumber
Erlang:https://github.com/marinakr/libphonenumber_erlang
Clojure: https://github.com/randomseed-io/phone-number
R: https://github.com/socialresearchcentre/dialr/
Regulars are not conditional operators. This is a complicated, but a template, and it’s not at all a fact that all your Wishlist can be solved with one regular expression. Especially since you're in a mess here. It can start with a number and with a bracket and with a plus sign, and inside there can be spaces and hyphens and brackets, and the number of digits is different.
If it's bad with regular expressions, do without it at all, or do a few if / else with simpler regular expressions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question