且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP Preg_Match精确匹配单词

更新时间:2021-10-13 15:43:19

如果只需要检查两个数字是否存在,请使用速度更快的strpos

if(strpos($mystring, '|7|') !== FALSE AND strpos($mystring, '|11|') !== FALSE)
{
    // Found them
}

或使用较慢的正则表达式捕获数字

preg_match('/|(7|11)|/', $mystring, $match);

使用regexpal免费测试正则表达式。