Hey I need a regex that would allow following input
matches: 0.1,1.1, 0.001, 1.4,

in short number should be less than 2.00.

Thanks for help.

Recommended Answers

All 4 Replies

Like this:

[0-9]+\.+[0-9]{3}
the numer in the {} is the number that you want after the dot.

didnt help. It allows 0000 and 121212 too. which is not correct.

didnt help. It allows 0000 and 121212 too. which is not correct.

Next time say exactly the range that you need:
[0-9]{1}+\.+[0-9]{3}

Next time say exactly the range that you need:
[0-9]{1}+\.+[0-9]{3}

It still allows 11111, 00000, even 222222. Is there anyway we could specify 0 or 1 before decimal point and anything else after .(point), the decimal part.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.