Re: Reg Exp Help

From: Date: Tue, 22 Oct 2002 20:06:58 +0000
Subject: Re: Reg Exp Help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-120975@lists.php.net to get a copy of this message
This works, too: $data = "Charles A. O'Brian-Brown, Jr. Esq."; if (!empty($data)) { $newdata = eregi_replace("[^a-zA-Z[:space:]\-]", "", $data); } echo $newdata; This produces: Charles A OBrian-Brown Jr Esq Monty > From: zach@populus.com (Zach Curtis) > Newsgroups: php.general > Date: Tue, 22 Oct 2002 12:37:47 -0600 > To: <php-general@lists.php.net> > Subject: Reg Exp Help > > I am having difficulty with creating a regular expression. I would like the > reg exp to remove anything other than alphas, dashes, and spaces. For > example, > > $data_array["cus01a"] = "Charles A. O'Brian-Brown, Jr."; > > if (!empty($data_array["cus01a"])) > $cus01a = eregi_replace("[^a-zA-Z\-]|^[[:space:]]", "", > $data_array["cus01a"]); > > echo $data_array["cus01a"]; > > This result produces, "CharlesAOBrian-BrownJr". I want it to produce > "Charles A OBrian-Brown Jr". > > Any thoughts... > > Regards. > > _________________ > Zach Curtis > Programmer Analyst > POPULUS > www.populus.com > _________________ >

« previous php.general (#120975) next »