About the pattern you tried:
Using this part in your pattern [+]?
optionally matches a plus sign. It is wrapped in an optional group ([+]?\d{1,2}[.-\s]?)?
possibly also matching 12 digits in total.
The character class [.-\s]
matches 1 of the listed characters, allowing for mixed delimiters like 333-333.3333
You are not using anchors, and can also possible get partial matches.
You could use an alternation |
to match either the pattern with the hyphens and digits or match only 11 digits.
^(?:\d{2}-\d{3}-\d{3}-\d{3}|\d{11})$
^
Start of string
(?:
Non capture group for the alternation
\d{2}-\d{3}-\d{3}-\d{3}
Match either the number of digits separated by a hyphen
|
Or
\d{11}
Match 11 digits
)
Close group
$
End of string.
Regex demo
If you want multiple delimiters which have to be consistent, you could use a capturing group with a backreference \1
^(?:\d{2}([-.])\d{3}\1\d{3}\1\d{3}|\d{11})$
Regex demo