Thursday, March 29, 2018

Match (a AND b) vs (a OR b) in PHP regex

I'm trying to search through some files in PHP and I want to give the user a choice between matching any or every term.



E.g.: Search terms: [apple,banana]



Is it possible to return only files that have both words in it?




Also my OR would use the following:



$s_terms = "(" . implode("|", explode(",", $s_terms)) . ")";



I want to separate terms with , and use it in a RegEx match like (apple|banana). Does the above code do that?



Thank you in forward



EDIT:




The other question did not answer my question, but I found something that works:
(.*apple.*banana.*)

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...