Reply to RegExp for a substring

Your name:

Reply:


Posted by Csaba Gabor on 06/14/06 11:29

Suppose I want to check that a string, $str, starts with at least the
first 3 letters of a given word, say "delete". Can I do that compactly
with a regular expression? The following are not my idea of compact:

preg_match("/^del(|e|et|ete)\\b/i", $str)
Quadratic in the length of the given word


preg_match("/^del(e(t(e)?)?)?\\b/i", $str)
Really now. But at least it's linear


Thanks.
Csaba Gabor from Vienna

[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

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