Page 1 of 1

this regular expression is acting funny

Posted: Mon Jun 17, 2002 11:49 pm
by chris12295
Ok, i made an expression to allow numbers in the format $123,456,789.99

but for some reason 3 and 5 do not run correctly. $3 and $5 do.

here is my code:

Code: Select all

<?
if(!ereg("^(\\$)?(&#1111;0-9]+|&#1111;0-9]&#123;1,3&#125;(,&#1111;0-9]&#123;3&#125;)*)(\.&#1111;0-9]&#123;1,2&#125;)?$", $price)) &#123;
	$invalidPriceMessage = "Price must be a number.";
	$wasAnError = "1";
	&#125;
echo "$wasAnError";
?>
3 and 5 cause $wasANError to be 1 but $3 and $5 dont. Whats going on?

Posted: Tue Jun 18, 2002 1:35 am
by roninblade
its because of your expression try changing the (\\$)? to (\\$?)