Regexp - How to match all words except strict ones? Regexp - How to match all words except strict ones? codeigniter codeigniter

Regexp - How to match all words except strict ones?


I would recommend taking a look at Rexegg — Word Boundaries.

If you want to match lines not containing "home" itself, you can do:

preg_match_all('/^(?!.*\bhome\b).*$/im', $str, $matches);

If you want to match the words alone:

preg_match_all('/\b(?!home\b)\w+/i', $str, $matches);