On 13 Nov 2004 15:15:02 GMT, Daniel Tryba <sp**@tryba.invalid> wrote:
Massimo at HOME <nu*********@gmail.com> wrote: I would like to substitute the "ac" substring when it is a single word
(i.e. "ac" or "ac " but not "ace" or "mace").
I tried something like:
ereg_replace("ac[^[:alpha:]]*","subst...",$inputstring));
But it fails...
Why use ereg_replace?
Why ask why? He was asking for help. Why demean his question?
$ cat /tmp/foo.php
<?php
$str='foo ac mace bar';
echo "before: $str\n";
$str=preg_replace('/\bac\b/','xx',$str);
echo "after : $str\n";
?>
$ php4 /tmp/foo.php
before: foo ac mace bar
after : foo xx mace bar
$
Neat answer, but I liked the first and yet similar response. The
poster wasn't a jerk and gave several URLs and a tip about \b so the
person asking the question could learn for himself.
--
gburnore@databasix dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== =========================
Want one? GET one!
http://signup.databasix.com
================================================== =========================