Link to home
Start Free TrialLog in
Avatar of jerrylmclaughlin
jerrylmclaughlin

asked on

eregi not working as expected

Hello -

I have the code below

 
 if(!eregi("^([0-9a-z-])+$", $subaddr1)){
            $custerror->c_error("session.php", "430","Addr1 is not alphanumeric");
            $form->setError($field, "* Address1 not alphanumeric");
}
if  I set $subaddr1= '4404 Normandy Ave'

the if statement evaulates to true and executes the error functions

Why?





Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

what about this:
if(eregi("^([0-9a-z ])+", $subaddr1)){
            $custerror->c_error("session.php", "430","Addr1 is not alphanumeric");
            $form->setError($field, "* Address1 not alphanumeric");
}
if (!eregi('^([a-z0-9[:space:]]+)$', $subaddr1)) {
$custerror->c_error("session.php", "430","Addr1 is not alphanumeric");
            $form->setError($field, "* Address1 not alphanumeric");      
      }
if(!eregi("^([\w[:space:]])+$", $subaddr1)){
            $custerror->c_error("session.php", "430","Addr1 is not alphanumeric");
            $form->setError($field, "* Address1 not alphanumeric");
}

or

if(!eregi("^([\w\s])+$", $subaddr1)){
            $custerror->c_error("session.php", "430","Addr1 is not alphanumeric");
            $form->setError($field, "* Address1 not alphanumeric");
}
Oh! Sorry! This:

--------------------------------------------------------------------------------------------
if(eregi("^([\w[:space:]])+$", $subaddr1)){
            $custerror->c_error("session.php", "430","Addr1 is not alphanumeric");
            $form->setError($field, "* Address1 not alphanumeric");
}
--------------------------------------------------------------------------------------------

or this:

--------------------------------------------------------------------------------------------
if(eregi("^([\w\s])+$", $subaddr1)){
            $custerror->c_error("session.php", "430","Addr1 is not alphanumeric");
            $form->setError($field, "* Address1 not alphanumeric");
}
--------------------------------------------------------------------------------------------
Avatar of jerrylmclaughlin
jerrylmclaughlin

ASKER

I will try these solutions, but know one answered my question. Why isn't that simple pattern in eregi not working?

It should work as is?
ASKER CERTIFIED SOLUTION
Avatar of Georgiana Gligor
Georgiana Gligor

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you tolagong and gicutza_cj

Angel III yours did not work, I assuming its due to the missing ! in front of the eregi