Reputation: 673
I want to replace a word with PHP preg_replace. It should not replace the word if the characters /> exist before this word.
i.e.
this should be replaced if matched
$word = "foo";
this should not be replaced if matched
$word = "/>foo";
Upvotes: 2
Views: 1520
Reputation:
if ($word[0] != '/' && $word[1] != '>') {
$new_string = str_replace($word, $replace, $string);
}
Upvotes: 0