Reply to Re: Regular Expression to validate password

Your name:

Reply:


Posted by Michael Fesser on 05/07/07 15:53

..oO(adzir)

>I need to validate password keyed in by the system users so that the
>password will contain only letters and numbers plus at least one
>capital letter. Exclude these symbols
>
>, < > ? / * ( ) & ^ % $ # ! ~ ` " '
>
>this is my code:
>
>ereg("[A-Za-z0-9[^\,\<\>\?\/\*\(\)\&\^\%\$\#\!\~\`\"\']]+$", $str)
>
>am i correct?

Way too complicated and using the old deprecated ereg* functions.

If the PW should only contain letters and digits, then use a pattern
that matches for exactly that:

preg_match('#[A-Z\d]+#i', $str);

If there has to be a capital letter somewhere in the PW, then try a
combination like this:

preg_match('#[a-zA-Z\d]*[A-Z][a-zA-Z\d]*#', $str);

HTH
Micha

[Back to original 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

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