Re: Inane ereg_replace question
| From: | mailing_list at gmx dot at | Date: | Sat, 03 Mar 2001 19:41:29 +0000 |
| Subject: | Re: Inane ereg_replace question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-42466@lists.php.net to get a copy of this message | ||
this will work:
ereg_replace(" *: *",":",$b);
I don't know why you use an OR!
If you only wanted to know WHY this doesn't work:
the searchstrings overlap (abc is poisitioned BEFORE cde - so the parser
only will see abc in abcdefghiabcdefghi but not cde in XdefghiXdefghi!!
$a="abcdefghi";
$a.=$a;
echo ereg_replace("abc|def","X",$a)."\n";
echo ereg_replace("def|abc","X",$a)."\n";
echo ereg_replace("abc|cde","X",$a)."\n";
echo ereg_replace("cde|abc","X",$a)."\n";
OUTPUT:
XXghiXXghi
XXghiXXghi
XdefghiXdefghi
XdefghiXdefghi
michi
> php 3.xx
>
> $a="to be or not : to to be";
>
> $b=ereg_replace(" *:",":",$b);
> $b=ereg_replace(": *",":",$b);
>
> works and
>
> $b=ereg_replace(" *:|: *",":",$b);
>
> does not work. I've had this problem before and ended
> up using two or more statments rather than one.
--
Sent through GMX FreeMail - http://www.gmx.net