Monday, August 23, 2010

basic regex help

Programmer Question

$string = 'word1 word2 "phrase 1" "phrase 2" -word3 -word4 -"phrase \"hello\" 3" -"phrase 4"';


i want to search strings that contains (word1 OR word2 OR 'phrase 1' OR 'phrase 2') AND doesn't contain (word3 OR word4 OR 'phrase "hello" 3' OR 'phrase 4')



what would be the regex that would parse $string for me?



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails