A strict formatted example
If your product requires a fixed mask, anchor the whole value.
Regex: ^\(\d{2}\) \d{5}-\d{4}$\nExample: (71) 99999-1234Optional punctuation increases complexity
The more input formats you accept, the harder the pattern becomes to read. Many systems normalize non-digits first and validate the normalized value.
International phone numbers
A single universal Regex becomes fragile because numbering plans vary. E.164 storage and specialized phone libraries are usually safer for international applications.
Validation and user experience
Do not punish users while they are still typing. Show a clear example, consider input masking, and validate when the entry is complete.
Next step: test it for real
Use the Playground to experiment with the pattern, then practice in the game with feedback on false positives and false negatives.