You are here: Re: php regular expression doesn't match « PHP Programming Language « IT news, forums, messages
Re: php regular expression doesn't match

Posted by Rik Wasmus on 10/24/07 10:11

On Wed, 24 Oct 2007 08:50:48 +0200, <cmk128@hotmail.com> wrote:

> Hi
> PHP's regular expression look like doesn't support .*? syntax. So i=

> cannot match the shortest match. For exmaple:
>
> $str=3D"a1b a3b";
> $str1=3Dereg_replace("a.*b", "peter", $str1);
> will produce "peter", but i want "peter peter", so how to?

use the preg_* functions

<?php
$str=3D"a1b a3b";
echo preg_replace("/a.*?b/", "peter", $str);
?>
-- =

Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация