|
Posted by Captain Paralytic on 10/24/07 10:18
On 24 Oct, 11:11, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Wed, 24 Oct 2007 08:50:48 +0200, <cmk...@hotmail.com> wrote:
> > Hi
> > PHP's regular expression look like doesn't support .*? syntax. So i
> > cannot match the shortest match. For exmaple:
>
> > $str="a1b a3b";
> > $str1=ereg_replace("a.*b", "peter", $str1);
> > will produce "peter", but i want "peter peter", so how to?
>
> use the preg_* functions
>
> <?php
> $str="a1b a3b";
> echo preg_replace("/a.*?b/", "peter", $str);
> ?>
> --
> Rik Wasmus
Mine was similar:
$strl = preg_replace('/(a.*b)*/','Peter',$strl);
[Back to original message]
|