preg_match in php example
Example 1: preg_match
if(!preg_match('/^\[a-zA-Z]+$/',$input)) {
// String contains not allowed characters ...
}
Example 2: preg_match in php
<?php
$my_url = "www.guru99.com";
if (preg_match("/guru/", $my_url))
{
echo "the url $my_url contains guru";
}
else
{
echo "the url $my_url does not contain guru";
}
?>