Make an entire grouped piece optional.
Section: Groups and Alternation
Optional group
regex
regex
^(?:\+1[-.\s]?)?\d{3}[-.\s]?\d{3}[-.\s]?\d{4}$Explanation
Common for optional prefixes in validators.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Groups and Alternation