What are some common pitfalls to avoid when using regular expressions for text manipulation in PHP?

One common pitfall when using regular expressions for text manipulation in PHP is not properly escaping special characters. To avoid this issue, always use the preg_quote() function to escape any special characters in the regular expression pattern.

$pattern = '/[.*+?^${}()|[\]\\]/';
$escaped_pattern = preg_quote($pattern, '/');