You are here: Re: [PHP] RegEx help « PHP « IT news, forums, messages
Re: [PHP] RegEx help

Posted by Philip Hallstrom on 10/14/87 11:13

>>> 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)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация