You are here: Re: regex question « PHP Programming Language « IT news, forums, messages
Re: regex question

Posted by Tim Roberts on 05/14/05 09:52

Henri Schomaecker <hs@byteconcepts.de> wrote:
>
>I solved it. It was a greedy problem.
>I just don't understand why in PHP .* catches far over the (...) when I
>don't set the N (non-greedy) Option. - In my Opinion it should at least
>stop matching, when the match-making ) is reached. - But it doesn't!

That's your opinion, because it conveniently suits your current
requirement. Regular expressions have been greedy right from the start.

>In perl, this is no problem, I tried a few one-liners with the g option
>(perl's greedy option) with my example now.

Perl is greedy by default (as are all regular expression matchers).
Perhaps you should post your test so we can figure out what you really did.

>PHP seems to match, and match ..., and does not stop with matching until the
>end of the subject string is found.

Please post your exact tests. I want to make sure we can explain this to
everyone.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

 

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

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