|
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]
|