Reply to Re: a regular expression inquiry

Your name:

Reply:


Posted by Rik on 06/10/06 00:55

Tim wrote:
> Yeah thats it.
>
> (.+)\s{2}
>
> Is a greedy match, it will match to the last two spaces it finds and
> not the first.
> Adding a ? after the brackets make it a non greedy match.
>
> (.+)?\s{2}


Good explanation, totally correct, but nort the right regex:
(.+)?\s{2}
means:
(A random character 1 or mor times) zero or once.

explanation was good, regex should be:

(.+?)\s{2}

As I've learned, correct me if I'm wrong, the ? to make a selector
non-greedy should be directly after the selector itself AFAIK.

Grtz,
--
Rik Wasmus

[Back to original 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

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