using preg_quote instead of replacing pipe and using htmlspecialchars