Regex with exception of particular words

前端 未结 6 1385
伪装坚强ぢ
伪装坚强ぢ 2021-01-12 03:45

I have problem with regex. I need to make regex with an exception of a set of specified words, for example: apple, orange, juice. and given these words, it will match everyt

6条回答
  •  生来不讨喜
    2021-01-12 04:19

    Something like (PHP)

    $input = "The orange apple gave juice";
    if(preg_match("your regex for validating") && !preg_match("/apple|orange|juice/", $input))
    {
      // it's ok;
    }
    else
    {
      //throw validation error
    }
    

提交回复
热议问题