Re: RegEx help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I wanted to create a regex that force a PHP form text field to meet the
following requirements:

a. Must contain an 1 uppercase letter. [A-Z]

b. Must contain 1 digit. [0-9]

c. Must be a minimum of 7 characters in length. {7}


if ( ereg("[A-Z0-9]", $field) && strlen($field) >= 7 ) { print("We have a winner!"); }
nope, a username like "1234567" would go trough ok. Which isn't what he wanted

that's what I get for thinking too fast :)

Seems like you should be able to do then um... "([A-Z]|[0-9])" as your regexp (check on escaping the ()'s or not. I can never remember)

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux