|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16358 Problem with ereg
Submitted: 2002-03-30 02:40 UTC Modified: 2002-03-31 22:04 UTC
From: webmaster at crescentart dot com Assigned:
Status: Not a bug Package: *Regular Expressions
PHP Version: 4.1.2 OS: Linux Red HAt 7.1
Private report: No CVE-ID: None
 [2002-03-30 02:40 UTC] webmaster at crescentart dot com
Since I have been using php I have had a problem with the ereg function not mathcing patterns properly.

For example I am trying the use ereg to ensure that users use passowrds that contain a combination of letters and numbers.

These are my HTML and PHP codes:

<input type="password" name="password">

if(!ereg("([a-zA-Z0-9])", "$password")){
   echo "Bad Password";

The problem that I encounter with ereg is that I have been able to enter passwords from the html form that do not contain numbers and or only have mixed case letters but ereg IF statment does match the pattern and echo "Bad Password".


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-30 03:48 UTC]
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit

 [2002-03-30 05:44 UTC]
You regex only matches on character. append a '+' at the end of the character-class modifier, e.g.
if (!eregi('^[a-z0-9]+$', ...
 [2002-03-30 15:33 UTC] webmaster at crescentart dot com
I have tried using your suggestion and I am still having a problem with ereg and eregi allowing entries with out numbers.

if(!eregi("^[a-z0-9]+$", "$pass")){

die("Your passowrd does not meet security requirments. Use your back button to make corrections.");

 [2002-03-31 05:46 UTC]
This is NOT a support forum!
 [2002-03-31 22:04 UTC] webmaster at crescentart dot com
I have found the error in my ereg script. Please discregard the bug report that I submitted.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 15 07:01:28 2024 UTC