Home >Backend Development >PHP Tutorial >PHP introductory learning knowledge point 4: Basic application of PHP regular expressions_PHP tutorial

PHP introductory learning knowledge point 4: Basic application of PHP regular expressions_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:27:07855browse

Copy code The code is as follows:

//regular expression
// ereg is case sensitive
if(ereg("([A-Z]{3,})", "AAA")){
echo "Capital letters match!
";
}else{
echo "no";
}
if(ereg("([A-Z]{3,})", "aaa")){
echo "yes";
}else{
echo "Lowercase cannot be matched!
";
}
// eregi is not case sensitive
if(eregi("([A-Z]{3,})","Aaaa")) {
echo "Can match both uppercase and lowercase letters!";
}
//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 ]
");
}
?>

30-minute introductory tutorial on regular expressions
Basic information on regular expressions

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323829.htmlTechArticleCopy the code The code is as follows: ?php //regular expression// ereg is case sensitive if(ereg("( [A-Z]{3,})", "AAA")){ echo "uppercase matches! br"; }else{ echo "no"; } if(ereg("([A-Z]{3,})", "a...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn