I understood the regex for my phone in the country, but I have something missing.
The rule is here: (Area Code) Prefix - Sufix
- Area code can be 3 to 5 digits
- The prefix can contain from 2 to 4 digits.
- Zone code + 7-digit prefix.
- The suffix is always 4 digits long
- Total numbers: 11.
I decided that I could have 3 simple regular expressions with OR "|" eg:
/(\(?\d{3}\)?[- .]?\d{4}[- .]?\d\d\d\d)|(\(?\d{4}\)?[- .]?\d{3}[- .]?\d\d\d\d)|(\(?\d{5}\)?[- .]?\d{2}[- .]?\d\d\d\d)/
What I'm doing wrong is that \d\d\d\donly 4 digits do not match for sufix, for example: (011) 4740-5000, which is a valid phone number, works fine, but if you add extra digits, it will also return as a valid number phone, i.e.: (011) 4740-5000000000