Regular expression in PHP for finding whole words

I want a code in PHP with regular expressions that returns whole words for any matches. For example if search for ac I want it returns all words in a string that have ac in any part. i.e. if the String have facebook or act or face it returns all the words to me, I wrote this code but does not work properly.

$regx = "/b(S)*ac(S)*/iu"; 
    foreach($values as $value) 
        echo $value."n";
        preg_match_all($regx, $value, $matches,PREG_PATTERN_ORDER);

Source: regex

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.