php match regex code example
Example 1: regex php
<?php
$str = "Visit W3Schools";
$pattern = "/w3schools/i";
echo preg_match($pattern, $str);
if (!preg_match("/[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+.[a-zA-Z]{2,4}/", $emailAddress)){
}
if(filter_var($emailAddress, FILTER_VALIDATE_EMAIL))
{
} else{
}
?>
Example 2: preg_match in php
<?php
$str = "Check For Testing.";
if (preg_match("/\bCheck\b/i", $str, $match))
echo "Matched!";
else
echo "not matched";
?>
Example 3: preg_match
if(!preg_match('/^\[a-zA-Z]+$/',$input)) {
}
Example 4: php regex
preg_match('/(foo)(bar)(baz)/', 'foobarbaz', $matches, PREG_OFFSET_CAPTURE);
Example 5: php preg_match
preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] ) : int