我有一个PHP代码来检查字符串内收集的字符串,我的代码是这样的:使用正则表达式来检查特定的字符串
$string = '01122028K,02122028K,03122028M-1';
$search = '03122029M'
echo preg_match('/\b' . $search . '\b/', $string);
它返回TRUE ...
我该怎么办与我的正则表达式返回它假,我希望它只返回TRUE当变量$ search中的字符串实际上匹配变量$字符串, 因此$ search =“03122029M”将返回FALSE $ search =“03122029M-1”会返回TRUE
谢谢你
这里看看http://stackoverflow.com/questions/5752829/regular-expression-for-exact-match-of-a-word – BenB 2013-03-13 17:20:30