Are there specific guidelines or documentation available for creating efficient RegEx patterns for preg_replace in PHP?

When creating efficient RegEx patterns for preg_replace in PHP, it is important to follow best practices to ensure optimal performance. This includes using specific RegEx modifiers only when necessary, avoiding unnecessary backtracking, and optimizing the pattern for the specific task at hand. Additionally, documenting the pattern and its purpose can help improve readability and maintainability of the code.

// Example of using efficient RegEx patterns with preg_replace
$pattern = '/\b(\w+)\b/i'; // Match whole words case-insensitively
$replacement = '<strong>$1</strong>'; // Wrap matched word in <strong> tags
$text = 'This is a sample text with words to highlight.';
$highlighted_text = preg_replace($pattern, $replacement, $text);
echo $highlighted_text;