What common mistake is made when using preg_replace in PHP?
One common mistake when using preg_replace in PHP is forgetting to use the delimiter character in the regular expression pattern. The delimiter helps to separate the pattern from the optional modifiers, making the expression more readable and less error-prone. To fix this issue, simply add the delimiter character (such as "/" or "#") at the beginning and end of the pattern.
// Incorrect usage without delimiter
$output = preg_replace("pattern", "replacement", $input);
// Corrected usage with delimiter
$output = preg_replace("/pattern/", "replacement", $input);