Home > Backend Development > PHP Tutorial > PHP regular PHP introductory learning knowledge point 4 Basic application of PHP regular expressions

PHP regular PHP introductory learning knowledge point 4 Basic application of PHP regular expressions

WBOY
Release: 2016-07-29 08:46:03
Original
1159 people have browsed it

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]
");
}
?>


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

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template