I'm trying to get something like:
Hello, 0 ( dont get )
Hello2, 100 ( get )
hello3, 82 ( get )
hello< 132 ( dont get )
I've made something like this so far:
[a-zA-Z]{1,255},([0-9]{1,3})(?<![0])
But it can't get 132
and 100
. How can I fix this?
Try this regex which matches a number of 1 or 2 digits, or 100:
\d{1,2}(?!\d)|100
Why not keeping it simple?
^[a-zA-Z]{1,255}, (100|[1-9][0-9]|[1-9])$
or better yet
^[a-zA-Z]{1,255}, (100|[1-9][0-9]?)$
note: this won't match prepended zeros e.g. "Hello, 00001". It can be easily extended, though:
^[a-zA-Z]{1,255}, 0*(100|[1-9][0-9]?)$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With