Currently I write the regex like this: /^([\\d+]*-)+([\\d]*-)+([\\d])*$/
I want the result follow this pattern 00-123-456-789
or 0012
@godwin: since I can't add a comment to your post and no one else seems to have responded, let me address at least one issue. At the beginning you have
[\d+]{2}\-
\d+
will match one or more digits and you're asking for it to be repeated twice, so the whole segment will match 123456789-
:
[\d+]
= 12345678
(greedy matching)[\d+]
= 9
\-
= -
You also probably didn't need to escape the dash because it's not inside a group block "[]"
.