f



Javascript regex lookaheads

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=-
0
tekboy23
7/21/2003 3:39:31 PM
comp.lang.javascript 38370 articles. 0 followers. javascript4 (1315) is leader. Post Follow

0 Replies
473 Views

Similar Articles

[PageSpeed] 55

Reply: