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 Erwin Moller on 10/24/07 14:07

Steve wrote:
> "Erwin Moller"
> <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> wrote in
> message news:471f0bf1$0$226$e4fe514c@news.xs4all.nl...
>> Erwin Moller wrote:
>>> cmk128@hotmail.com wrote:
>>>> Hi
>>> Hi,
>>>
>>>> PHP's regular expression look like doesn't support .*? syntax. So i
>>>> cannot match the shortest match. For exmaple:
>>>>
>>>> $str="a1b a3b";
>>> Typo. That was $str1="a1b a3b" I expect.
>>>
>>>> $str1=ereg_replace("a.*b", "peter", $str1);
>>>> will produce "peter", but i want "peter peter", so how to?
>>>>
>>> Yes, * is greedy.
>>> I do not know your real-world example, but maybe using a wordboundary
>>> can solve your problem?
>>> eg:
>>> $str1=ereg_replace("/a.*b\b/", "peter", $str1);
>> That is nonsense. (Erwin had a coffee now.)
>> It doesn't solve the greedinessproblem.
>> Excuse me for the noise.
>>
>> A better solution would be to explode the string first on space, and use
>> a regexpr to modify if matched.
>
> uhhh...bullshit.
first, there is no need. second, you assume you know what
> he wants based on the test string. be logical! his string may very well be
> 'a1ba2ba3b'. if he becomes more specific with us about what he wants, THEN
> you'll be able to make such leaps...and be a bit more accurate. your 'better
> solution' is tripe. as others have pointed out:
>
> preg_replace('/a.*?b/', 'peter', 'a1ba2ba3b');
>
> with heavy emphasis on PREG...THAT is the only solution warranting
> attention.
>
> you seem to think coffee helps you out. i recommend you go make two or three
> more pots.
>


Bullshit? More pots of coffee?

If you want to appear smart, you better first read the other response I
wrote in this same thread many hours ago.
It contained a better solution. One that actually works and solves the
OP problem.

I fixed my own nonsense with a good solution that works in the other
response.
Will you do the same and fix the insulting crap you wrote about me in here?

Erwin Moller

 

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

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