Re: regex newbie question
| From: | Jonathan Sharp | Date: | Wed, 23 Oct 2002 18:31:40 +0000 |
| Subject: | Re: regex newbie question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-121152@lists.php.net to get a copy of this message | ||
Personally I prefer to use preg (perl regular expressions)
if ( preg_match('/^[a-z0-9\s]+$/i', $field) )
{
$field_valid = true;
}
-js
David Pratt wrote:
Hoping someone can help with something probably quite simple
I am using regex to validate user input this way:
if (ereg ("^[a-zA-Z0-9\s]+$", $field)) {
$field_validate = TRUE;
}
I am trying to get the expression to accept upper or lower case letters and
numbers and also allow spaces. It works when I test the expression at
http://regexlib.com/RETester.aspx but I can't seem to get it to work with
expressions with white space between words or numbers. Anyone have an easy
fix?
Thanks