$str = 'hellow, when i am working, do not coming, this question is really ,let us test some words complex,luck,unlucky,state,unhappy,test,generator,unset';
//把ing结尾的单词词根部分找出来,找到work,com
//前瞻,断言,零宽度,正预测
$patn = '/\b\w+(?=ing\b)/';
// preg_match_all($patn,$str,$res);
//把不是ing结尾的单词找出来,但单词长度必须大于3(ing长度)
//前瞻,断言,零宽度,负预测
$patn2 = '/\b\w+(?!ing)\w{3}\b/';
// preg_match_all($patn2,$str,$res);
//把un开头的单词词根部分找出来
//回顾,断言,零宽度,正预测
$patn1 = '/(?<=\bun)\w+\b/';
// preg_match_all($patn1,$str,$res);
//把不是un开头的单词找出来
//断言,零宽度,负预测,回顾
$patn3 = '/\b(?!un)\w+\b/';
preg_match_all($patn3,$str,$res);
echo '
';
print_r($res);
echo '';
网友评论