^((\d){4}|(\d){6})$ , ^([0-9]{4}|[0-9]{6})$ p>
Both writing methods are OK. Only match 4 or 6 characters.
I don’t know if you want negative numbers. This does not match negative numbers.
Including 0