How can the usage of regular expressions in PHP, such as with preg_match(), impact the functionality and reliability of code?

Using regular expressions in PHP, such as with preg_match(), can impact the functionality and reliability of code if not used correctly. Improperly written regular expressions can lead to unexpected behavior, performance issues, and security vulnerabilities. It is essential to thoroughly test and validate regular expressions to ensure they work as intended and handle edge cases properly.

// Example of using preg_match() with proper validation

$email = "example@example.com";

if (preg_match('/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/', $email)) {
    echo "Valid email address";
} else {
    echo "Invalid email address";
}