Currently I write the regex like this: /^([\\d+]*-)+([\\d]*-)+([\\d])*$/
I want the result follow this pattern 00-123-456-789
or 0012
From what have you provided us, this regex ^-?(\d+-?)+$
matches this
-00-123-456-789-
-00123456789-
00-123-456-789-
00123456789
but doesn't match this:
00-123--457-789
Breakdown:
^-?
)\d+-?
)(\d+-?)+
)$
)