core-bundle/src/Resources/contao/library/Contao/StringUtil.php
public static function censor($strString, $varWords, $strReplace='')
	{
		foreach ((array) $varWords as $strWord)
		{
			$strString = preg_replace('/\b(' . str_replace('\*', '\w*?', preg_quote($strWord, '/')) . ')\b/i', $strReplace, $strString);
		}

		return $strString;
	}
public static function censor($strString, $varWords, $strReplace='')
	{
		foreach ((array) $varWords as $strWord)
		{
			$strString = preg_replace('/\b(' . str_replace('\*', '\w*?', preg_quote($strWord, '/')) . ')\b/i', $strReplace, $strString);
		}

		return $strString;
	}
Censor a single word or an array of words within a string

@param string $strString  The string to censor
@param mixed  $varWords   A string or array or words to replace
@param string $strReplace An optional replacement string

@return string The cleaned string