How to write regex to validate this pattern?
123456 - correct
*1 - correct
1* - correct
124** - correct
*1*2 - correct
* - correct
123456* - incorrect (size 7)
12345 - incorrect (size 5 without stars)
tried:
^[0-9]{6}$|^(([0-9]){1,6}([*]){1,5}){1,6}+$
But it allows to have more than 6 numbers and don’t allow for star to be before number.
There is no minimum/maximum count of “*” sign (but max count for all signs is 6).
Here you go:
Here is what it does:
I’m not quite sure if you want the empty case (but you said 0 to 6), if you actually want 1 to 6 just remove the last
|