You are here: Re: quantifier minimizer « PHP Programming Language « IT news, forums, messages
Re: quantifier minimizer

Posted by John Dunlop on 05/22/05 13:09

yawnmoth wrote:

> <?
> echo preg_replace('#.*?b#','','aabbc');
> ?>
>
> Based on my understanding of the quantifer minimizer, the output should
> be bc. However, running this results in c being outputted.

Your understanding of <?> is probably spot on but you've just
overlooked the Kleene Star. There's in fact two replacements
here. The first is the one you expected, the replacement of
<aab> with the empty string. The second is the replacement of
<b> - the second <b>. The quantifier <*> means zero or more;
and so in the second replacement, <.*> matches nothing while
the <b> matches.

--
Jock

 

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

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