What are the implications of using regular expressions to detect specific patterns in text input for PHP applications?

Regular expressions can be powerful tools for detecting specific patterns in text input for PHP applications. However, they can also be resource-intensive and may slow down the application if not used efficiently. To mitigate this issue, it is important to optimize regular expressions by using them judiciously and avoiding overly complex patterns.

// Example of using a regular expression to detect email addresses in a string
$input_text = "Please contact me at user@example.com for more information.";
$pattern = '/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/';
if (preg_match($pattern, $input_text, $matches)) {
    echo "Email address found: " . $matches[0];
} else {
    echo "No email address found.";
}