Page 1 of 1
Contain all of the string listed, regardless of display orde
Posted: Thu Aug 21, 2008 8:39 am
by coldwinds
We know that in [a|b|c] the '|' represent 'or', how to present a 'and' condition to match a string? like a&b&c ? regardless of appearing order of a b c in the string.
How could it been done with regexp?
Re: Contain all of the string listed, regardless of display orde
Posted: Thu Aug 21, 2008 8:52 am
by ghurtado
Regular expressions are always position based. So if you need to account for all combinations of those three letters you need to be explicit.
Re: Contain all of the string listed, regardless of display orde
Posted: Thu Aug 21, 2008 9:20 am
by coldwinds
Thx for your reply, ghurtado.
Re: Contain all of the string listed, regardless of display orde
Posted: Thu Aug 21, 2008 2:15 pm
by deejay
i'm not very good at regex and there's probably loads of ways to skin this cat ( would be interested to read of others to help my learning of regex) but wouldn't something like
achieve the same and be easier to write
Re: Contain all of the string listed, regardless of display orde
Posted: Thu Aug 21, 2008 2:21 pm
by ghurtado
It would not be the same if you need to guarantee that there is at least one of each a, b or c, since "aaa" would match your regexp. At the same time, I don't really know if that was a requirement of the OP, I just kindof assumed.
Re: Contain all of the string listed, regardless of display orde
Posted: Thu Aug 21, 2008 3:31 pm
by prometheuzz
coldwinds wrote:We know that in [a|b|c] the '|' represent 'or', how to present a 'and' condition to match a string? like a&b&c ? regardless of appearing order of a b c in the string.
How could it been done with regexp?
Note that inside the square brackets (character class or character set), the pipe symbol is not a logical OR, but matches just the character '|'.
Re: Contain all of the string listed, regardless of display orde
Posted: Fri Aug 22, 2008 3:23 am
by GeertDD
I think this is a job for
strpos() rather than a regular expression.
Re: Contain all of the string listed, regardless of display orde
Posted: Fri Aug 22, 2008 7:06 am
by deejay
yeah your right ghurtado.
I get it now
