regex problem
Posted: Fri Dec 15, 2006 2:51 am
ok, i confess, regex is my achillies heel! ive been getting better at it but ive become a bit unstuck in my aim to validate certain fields in some form data.
basically i was trying to verify a price field, only allowing the format:
optional £
one or more digits
"."
2 digits
e.g. £1.00, 1.00 ok
1.0 not ok
i got as far as verifying the x.xx part of the string but im not entirely happy with the code as 1.11111 matches because 1.11 appears in the string as a substirng.
also, another simliar field i have needs to accept numeric values in this form:
25 or 25.0 or 25.00
any help would be much appreciated.
thanks
basically i was trying to verify a price field, only allowing the format:
optional £
one or more digits
"."
2 digits
e.g. £1.00, 1.00 ok
1.0 not ok
i got as far as verifying the x.xx part of the string but im not entirely happy with the code as 1.11111 matches because 1.11 appears in the string as a substirng.
also, another simliar field i have needs to accept numeric values in this form:
25 or 25.0 or 25.00
any help would be much appreciated.
thanks