Are you wanting the $_POST['nums1'] to have only numbers, -, ., #, : ????

Is this what you are trying to match.  if so, try this.

if ( preg_match("/[^0-9\#\:\.\-]/", $_POST['nums1']) ) {
  throw error()
}

This will match anything that is not a number or one of the other special
chars that are in the pattern to be matched.

Therefor, if it does find anything that is not in the pattern to be matched
it will return true and then it will enter the if statement instead of
skipping over it.

Jim Lucas
----- Original Message -----
From: "Daniel J. Rychlik" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, May 31, 2003 11:46 AM
Subject: [PHP] regex problem


Hello,,

I have a preg_match issue matching numbers.  I am currently using

!preg_match ('/([0-9\-\.\#:])/', $_POST['nums1']
    throw error[]

This fails if you use something like ' asdf ' but if you use ' asdf789 ' it
passes false and does not throw an error.
This is not the obvious solution....  I know its a problem in my regular
expression.  Should I ONLY be using

' /([0-9])/ ' ,  ?

Thanks in advance.
Daniel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to