php入门学习知识点四 PHP正则表达式基本应用,正则也是php中常用的,大家一定要掌握下。不会的可以到脚本之家首页查看正则基础教材。
代码如下:
//正则表达 式
// ereg区分大小写
if(ereg("([A-Z]{3,})", "AAA")){
echo "大写能匹配!
";
}else{
echo "no";
}
if(ereg("([A-Z]{3,})", "aaa")){
echo "yes";
}else{
echo "小写不能匹配!
";
}
// eregi不区分大小写
if(eregi("([A-Z]{3,})","Aaaa")){
echo "大小写都可以匹配!";
}
//返回匹配的值
if(ereg("^(0[0-9]{2,3})-([0-9]{7,8})","0592-5337138",$regs)){
echo "返回值0下标为原串$regs[0]
";
echo "返回区号(即第一个匹配串)".$regs[1]."
";
echo("返回电话号码(即第二个匹配串)$regs[2]
");
}
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)