This has already been shared in a comment, but just to provide a complete-ish answer…
You have these tools at your disposal:
xmatchesxexactly oncex{a,b}matchesxbetweenaandbtimesx{a,}matchesxat leastatimesx{,b}matchesxup to (a maximum of)btimesx*matchesxzero or more times (same asx{0,})x+matchesxone or more times (same asx{1,})x?matchesxzero or one time (same asx{0,1})
So you want to use that last one, since it’s exactly what you’re looking for (zero or one time).
/\d{3}[^0-9a-zA-Z]?\d{2}[^0-9a-zA-Z]?\d{4}/