Javascript regex lookaheads

T

Tek Boy

I have a regular expression that makes sure an input string is a
decimal value, the values of which are limited to 0.50 increments.
For example, 10.00, 31.5 and 0.5000000 would all be valid.

^[0-9]{1,}(\.[0]{0,}|\.5[0]{0,})?$


I had initially planned on using lookaheads [e.g. x(?=y)] to make sure
that a decimal should only be recognized if a value comes after it. I
was trying to do something like this (initially just to match a
decimal value with 2 zeros after it):

^[0-9]{1,}\.(?=00)$


But even that didn't work. What am I missing? Thanks in
advance..........



-=Tek Boy=-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,077
Messages
2,570,566
Members
47,202
Latest member
misc.

Latest Threads

Top