I try to write a regex to validate a pattern, but I have some problems. This the pattern that I should get and validate using a regex
XXXX
XXXX-XXXX
XXXX-XXXX-XXXX-XXXX-XXXX
Every X is an Int number [0-9]
I'm trying with this :
[0-9]{4}(-?[0-9]{4})?
but it gives me this pattern :
**4586-4584**-**5588-5558**-**5888-5545**
Any idea how to fix this problem? Thanks in advance!

^[0-9{4}(?:-[0-9{4})*$XXXX(with hyphens, of course)?