Regualr Expression

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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 -


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,



Re: Regualr Expression

Quoted text here. Click to load it


Will require 5 words, but this will still let your user enter the same
word 5 times. Do you need an instance of all 5 words?

Re: Regualr Expression

willl69 schreef:
Quoted text here. Click to load it

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)/',
          PREG_SPLIT_NO_EMPTY))) {
     print 'unknown words found';


Re: Regular Expression

That would work, however i need it in the one regular expression if
possible as it needs to port across platforms (ie php, mysql, perl).  Its
highly possible that it is completely impossible, just trying to save my
self extra coding

Re: Regular Expression

Quoted text here. Click to load it

The only way I see it done in a regular expressions is a hidous nested  
beast of a regex, which details all of the possibilities. Regex is  
certainly no way to go here.
Rik Wasmus

Site Timeline