> -----Original Message-----
> From: Paul Battley [mailto:pbattley / gmail.com]
[...]
> On 27/06/06, Ben Nagy <ben / iagu.net> wrote:
> > then I got:
> >
> > str.sub(/\d{2}/,'\0-').gsub(/\d{4}(?!$)/,'\0-')
>
> str.gsub(/(?:^\d{2}|\d{4}(?=.))/, '\0-')
>
> Paul

Although it's derivative, if you sacrifice a little precision (bad inputs
will kill the regexp solutions anyway) then:

str.gsub(/^..|.{4}(?!$)/,'\0-')

seems to work for me... ;)

ben