In PHP, what are some potential pitfalls to be aware of when trying to remove specific characters like separators while preserving certain formatting elements like dashes within the text?

When trying to remove specific characters like separators while preserving certain formatting elements like dashes within the text, a potential pitfall is accidentally removing the dashes as well. To solve this issue, you can use regular expressions to target the specific characters you want to remove while excluding dashes from the replacement.

$text = "123-456-7890";
$removed_separators = preg_replace('/[() -]/', '', $text);
echo $removed_separators; // Output: 123-456-7890