Copy code The code is as follows:
//regular expression
// ereg is case sensitive
if(ereg("([A-Z]{3,})", "AAA" )){
echo "uppercase matches!
";
}else{
echo "no";
}
if(ereg("([A-Z]{3,})", "aaa")) {
echo "yes";
}else{
echo "Lowercase cannot match!
";
}
// eregi is not case sensitive
if(eregi("([A-Z]{3,})" ,"Aaaa")){
echo "Can match both upper and lower case!";
}
//Return the matching value
if(ereg("^(0[0-9]{2,3})-([ 0-9]{7,8})","0592-5337138",$regs)){
echo "The return value 0 subscript is the original string $regs[0]
";
echo "Return the area code (i.e., the first matching string) ".$regs[1]."
";
echo("Return the phone number (i.e., the second matching string)$regs[2]
");
}
?>
The above introduces PHP regular PHP introductory learning knowledge point 4. Basic application of PHP regular expressions, including PHP regular content. I hope it will be helpful to friends who are interested in PHP tutorials.