What are the best practices for using delimiters in regex patterns in PHP?

When using regular expressions in PHP, it is important to choose appropriate delimiters to wrap around your pattern. This helps improve readability and avoid conflicts with special characters within the pattern. Common delimiters include forward slashes (/), hash symbols (#), and tildes (~). It is also recommended to escape any delimiter characters that appear within the pattern to prevent syntax errors.

// Example of using forward slashes as delimiters
$pattern = '/^Hello, World!$/';

// Example of using hash symbols as delimiters
$pattern = '#^Hello, World!$#';

// Example of escaping delimiter characters within the pattern
$pattern = '/^https:\/\/www\.example\.com\/$/';