preg_match. | is for OR, can you simply do an AND ?
Posted: Wed Aug 17, 2005 8:01 am
I have a list of search parameters say alpha, beta and gamma and I need to compare them with a string.
the '.*(alpha|beta|gamma).*' pattern can check if one of these exists but I need to check if they all exist within the string in any order. Is there a simple way of doing this (back references or some such). I have tried to read up the syntax in the manual but must admit the explanations of the more complex features are double dutch to me
.
I know I could do each of the "options" in its own match or even a pattern like '.*(alpha.*beta.*gamma|.*beta.*alpha.*gamma|.*beta.*gamma.*alpha|.... all combinations' but there must be a better way.
Thanks for any assistance.
the '.*(alpha|beta|gamma).*' pattern can check if one of these exists but I need to check if they all exist within the string in any order. Is there a simple way of doing this (back references or some such). I have tried to read up the syntax in the manual but must admit the explanations of the more complex features are double dutch to me
I know I could do each of the "options" in its own match or even a pattern like '.*(alpha.*beta.*gamma|.*beta.*alpha.*gamma|.*beta.*gamma.*alpha|.... all combinations' but there must be a better way.
Thanks for any assistance.