需要帮助创建一个不匹配的正则表达式模式

时间:2011-02-06 21:14:24

标签: php regex

我正在尝试创建一个正则表达式模式,如果找不到某个单词,则返回true。我曾尝试使用[^ word],但这与单个字符出现时的单词不匹配。

我需要preg_match(使用php)返回true,因为还有其他单词我要匹配并返回true。

2 个答案:

答案 0 :(得分:1)

如果你在字符串中寻找一个字符串(不需要模式),那么使用strstr()或stristr()

答案 1 :(得分:0)

if (!preg_match("/word/", $string)) { // <-- true, if not match
    // code here
}
相关问题