What is a Regular Expression in php
<?php
// First Verif your regex code with https://regex101.com/
$str = "Visit W3Schools";
$pattern = "/w3schools/i";
echo preg_match($pattern, $str); // Outputs 1
// test email with REGEX
if (!preg_match("/[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+.[a-zA-Z]{2,4}/", $emailAddress)){
//Email address is invalid.
}
// use filter var to valide Email
if(filter_var($emailAddress, FILTER_VALIDATE_EMAIL))
{
//The email address is valid.
} else{
//The email address is invalid.
}
?>
A regular expression is a sequence of characters that forms a search pattern.
Also in PHP:
- error messaging php
- Call Python From PHP And Get Return Code
- How to display MySQL data dynamically using jQuery and PHP
- SET CURRENT DATE TIME IN PHP'
- composer install laravel 7 not installing
- composer global laravel
- array_unique
- CONTAIN PHP
- contains function in php
- DependencyResolver/RuleSet.php on line 84
- PackageManifest.php line 131: Undefined index: name
- check if a string contains a word in php
- create a folder php
- create random unique string
- add floater to open a modal in wordpress
- Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
- fetch today data in php
- alias seeddb='php artisan db:seed'
- date formate with timestamp php
- Str slug laravel
- check string contain symbol in php
- Created Migration: laravel
- array_search in php
- Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.3.0". php 8