I think the technique used in
Generating regex strings with a regex might be
adapted to your problem. Using (?{}) blocks allows
you to get inside regex processing to a degree.
The Regexp::Genex module based on the above
transforms a regex using YAPE::Regex,
you could write a similar transform to answer your
question. The transformed version would have to
be peppered with an illegible sequence of (?{}) terms
although I don't know what form it would take.
Something like:
/^(\d(\d(\d(-(\d(\d(\d$)|$)|$)|$)|$)|$)|$)/