I have a regex that tries to match for 2 or more words, but it isn\'t working as it\'s suppose to. What am I doing wrong?
$string = \"i dont know , do you know?\
This will match for string that contains exactly 2 words or more:
/([a-zA-Z]+\s?\b){2,}/g
you can go http://www.regexr.com/ and test it
PHP:
$string = "i dont know , do you know?";
preg_match("/([a-zA-Z]+\s?\b){2,}/", $string, $match);
echo "";
print_r($match);
echo "
";
Note: do not use the /g in the PHP code