str_replace isn't near enough for this.
d11wdq, thanks. You didn't escape your backslash enough, though.

(\\\\)
If you're interested, I ended up with this. I'll probably have to edit and fix things later, but this'll do for now.
Code: Select all
$bad = array(
'/(?<!\\\\)\br\b/i',
'/(?<!\\\\)\bn\b/i',
'/(?<!\/)\bu\b/i',
'/\b(t)h(?:an)x\b/i',
'/!!(?:!)+/',
'/\by\b/i',
'/(?<!\/|\[)\bi\b/',
'/\b(n)oone\b/i',
'/\bdat\b/i',
'/\bsi\b/i',
'/\b(sooo)o+\b/i',
'/\b(d)ud\b/i',
'/\bur\b/i',
'/\b(y)oure\b/i',
'/\bi(m|ll|ve)\b/i',
'/\b(ca|wo|do|did|was)nt\b/i',
'/\b(p)pl\b/i',
'/\b(w)elcom\b/i',
'/\bnoe\b/i',
'/\b(m)abye\b/i',
'/\b(g)[2t](g)\b/i',
'/\bne(?=\b|one)/i',
'/\bne1\b/i',
'/\b(r)ealli\b/i',
);
$b = '<span style="color: #00c;" class="ltt">'; $e = '</span>';
$good = array(
$b.'are'.$e,
$b.'in'.$e,
$b.'you'.$e,
$b.'\\1hanks'.$e,
$b.'!!'.$e,
$b.'why'.$e,
$b.'I'.$e,
$b.'\\1o one'.$e,
$b.'that'.$e,
$b.'is'.$e,
$b.'\\1'.$e,
$b.'\\1ude'.$e,
$b.'you\'re'.$e,
$b.'\\1ou\'re'.$e,
$b.'I\'\\1'.$e,
$b.'\\1n\'t'.$e,
$b.'\\1pl'.$e,
$b.'\\1elcome'.$e,
$b.'know'.$e,
$b.'\\1aybe'.$e,
$b.'\\1ot to \\2o'.$e,
$b.'any'.$e,
$b.'anyone'.$e,
$b.'\\1eally'.$e,
);
$txt = preg_replace($bad,$good,$txt);