What are some best practices for handling delimiters in regular expressions in PHP?

When using delimiters in regular expressions in PHP, it is important to choose delimiters that do not conflict with the pattern itself. One common delimiter is the forward slash (/), but if your pattern contains forward slashes, you should choose a different delimiter such as a hash symbol (#). Additionally, it is recommended to use the preg_quote() function to escape any delimiter characters within the pattern to prevent unexpected behavior.

$pattern = '/example\/pattern/';
$pattern = preg_quote($pattern, '/');