1

i'm trying to create a regex pattern that returns true if a certain word is not found. Ive tried using [^word] but that doesn't match up against a word just the individual characters as they appear.

I need preg_match(using php) to return true cause there are other words that I to match and return true.

Incognito
  • 1,883
  • 5
  • 21
  • 28
  • possible duplicate of [Regular expression to match string not containing a word?](http://stackoverflow.com/questions/406230/regular-expression-to-match-string-not-containing-a-word) – Bart Kiers Feb 06 '11 at 21:28

2 Answers2

1

if you are looking for a string within a string (no pattern needed) then use strstr() or stristr()

CrayonViolent
  • 32,111
  • 5
  • 56
  • 79
0
if (!preg_match("/word/", $string)) { // <-- true, if not match
    // code here
}
realmfoo
  • 433
  • 3
  • 11