You are here: Re: Regualr Expression « PHP Programming Language « IT news, forums, messages
Re: Regualr Expression

Posted by Janwillem Borleffs on 02/23/07 12:27

willl69 schreef:
> Just wondering if anybody can help me out with a regular expression.
>
> What i need to do is match a sting of 5+ words, with the words in any
> order. The below will perform the operation -
>
> ^(word1|word2|word3|word4|word5)+$
>
> Although this works, this will also match alot of stuff that contains any
> of those words, not contains all the words, which is what i need.
>
> Any info greatly appreciated, i can ellaborate on the problem if needed,
>

The following will report invalid words, but won't check that all words
are present:

$sentence = 'word1word2';

if (count(preg_split('/(word1|word2|word3|word4|word5)/',
$sentence,
-1,
PREG_SPLIT_NO_EMPTY))) {
print 'unknown words found';
}


JW

 

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

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