Q:

Regex number format no consercutive - - in between number

I current have this regex:
/^\+?\d+(\d|\-)+\d+$/

this accepts
12345
123-456
+12345
+12345-12345

my problem that this also accepts
123--123
123-------3242-324324

How can I fix the regex to not accept consecutive dash in between numbers?

A:

This will be correct one
^\+?\d+(-\d+)*$ 

Regex Demo
or modifying a bit of your regex with negative lookahead will also work
^(?!.*--)\+?\d+(\d|\-)+\d+$

Regex Demo

