duanlu6114 2016-10-20 14:48
浏览 110
已采纳

警告:preg_match()[function.preg-match]:编译失败:在偏移22处不重复

i'm trying to change the preg_match check from url checking and i'm getting this error

Blockquote preg_match_all(): Compilation failed: nothing to repeat at offset 22

this is the code:

preg_match_all('#\b(' . $allWordsFromProduct . ')\b#ui', $name, $matches);
  • 写回答

1条回答 默认 最新

  • dongping5230 2016-10-20 15:05
    关注

    May $allWordsFromProduct contains special regex character. You can try:

     $allWordsFromProduct = preg_quote($allWordsFromProduct , '#');
     preg_match_all('#\b(' . $allWordsFromProduct . ')\b#ui', $name, $matches);
    

    This will escape them.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?