把ing结尾的单词的词根找出来
$str = 'hello, when i am working, do not walking';
$patt = '/\b\w+(?=ing\b)/';
preg_match_all($patt,$str,$matches);
print_r($matches);
// Array ( [0] => Array ( [0] => work [1] => walk ) )
把un开头的单词词根找出来
$str = 'luck ,unlucky, state, unhappy';
$patt = '/(?<=\bun)\w+\b/';
preg_match_all($patt,$str,$matches);
print_r($matches);
// Array ( [0] => Array ( [0] => lucky [1] => happy ) )
把非un开头的单词词根找出来
$str = 'luck ,unlucky, state, unhappy';
$patt = '/\b\w{2}(?<!un)\w*\b/';
preg_match_all($patt,$str,$matches);
print_r($matches);
// Array ( [0] => Array ( [0] => luck [1] => state ) )