What are some potential pitfalls when using regular expressions in PHP, especially when dealing with special characters like minus signs?

When using regular expressions in PHP, special characters like minus signs can cause issues if not properly escaped. To avoid pitfalls, always escape special characters using a backslash (\) before them in your regular expression patterns.

// Example of properly escaping a minus sign in a regular expression pattern
$string = "10 - 5 = 5";
$pattern = '/\d+\s-\s\d/';
if (preg_match($pattern, $string)) {
    echo "Match found!";
} else {
    echo "No match found.";
}