What are some common pitfalls when using regular expressions in PHP, as seen in the provided code snippet?

One common pitfall when using regular expressions in PHP is not properly escaping special characters. This can lead to unexpected behavior or errors in the regex pattern matching. To solve this issue, it is important to use the preg_quote() function to escape special characters before using them in the regex pattern.

// Incorrect regular expression pattern without escaping special characters
$pattern = "/[a-z]+/";

// Corrected regular expression pattern with special characters escaped
$pattern = "/" . preg_quote("[a-z]+") . "/";