I'm trying to make it so that the following are able to fit into the regex, but I'm not able to make it work.
I'm using js on regex101 for this.
These should pass
3
3.4
3.5.3
2.5.*
3.*
These should fail
33.2
2.
3.1.2.
.2
3.1.2.
....
My current regex is \d?[\.?]?
This only approves 3
. I try going forward and use \d?[\.?\d?]?
but it still only allows 3
.
Edit: 3.5
technically passes in the way that 3.
and 5
pass individually but not together. How can I make it together?
Why isn't it working on the rest of the numbers? And how do I fix it?
Update: Please explain how the regex does work if you manage to find it. Thank you.