replace exact word in php code example Example: replace exact word in php $string = preg_replace('/\bthe\b/', '', $string);