当前位置:网站首页>Regular expressions (regular matching)
Regular expressions (regular matching)
2022-06-30 18:58:00 【*Xiaoyao】
Regular expressions
A regular expression consists of two parts
atom ( Match content )+ Metacharacters ( Number of matches )
atom :
Metacharacters :
The most important thing is ** practice ** 了 , You can take a look at the following commonly used , You can also go to the rookie tutorial to see other
This time I'll show you some of these functions ( Applications in life ):
Regular matching mailbox number
Regular matching phone number
Match URL
Verify that the real name is Chinese characters
Hide numbers in mobile numbers
String split into arrays
<?php
// Simple regular matching : atom + Metacharacters
$a="[email protected]_q.cm";
$b="19139567866";
$c="https://www.baidu.com";
$d=" Zhang San ";
$check2=preg_match("/^\[email protected]\w+\.[0-9a-zA-Z]{2,4}$/",$a);// Regular matching mailbox number
$check1=preg_match("/^1[0-9]{10}$/",$b);// Regular matching mailbox number
$check3=preg_match("/^https?:\/\/\w+\.\w+/",$c);// Match URL , The last Terminator $ To get rid of Can also be written as "/^(http)|(https):\/\/\w+\.\w+/"
$check4=preg_match("/^[^u4E00-u9FA5]{4,10}$/",$d);// Verify that the real name must be in Chinese characters , One Chinese character has two lengths ,[4,10] Express 2-5 A word
echo $check5=preg_replace("/[123]/","*",$b,2);// Hide numbers in mobile numbers ,2 Indicates that only two numbers are hidden
echo"<br>";
$check6=" Zhang San , Li Si , Wang Wu # Old six ";// String split into arrays
$arry1=explode(",",$check6);
$arry2=preg_split("/[#,]/",$check6);
print_r($arry1);
echo "<br>";
print_r($arry2);
if($check1&&$check2&&$check3&&$check4)
{
echo('<br>zq');}
else{
echo("cuowu");}
边栏推荐
- Classic problem of leetcode dynamic programming (I)
- How to do a good job in software system demand research? Seven weapons make it easy for you to do it
- PHP uses queues to solve maze problems
- 拓维信息使用 Rainbond 的云原生落地实践
- Tensorflow2 ten must know for deep learning
- Adhering to the concept of 'home in China', 2022 BMW children's traffic safety training camp was launched
- PC端微信多开
- Small program container technology to promote the operation efficiency of the park
- ONEFLOW source code parsing: automatic inference of operator signature
- 【TiDB】TiCDC canal_json的实际应用
猜你喜欢

充值满赠,IM+RTC+X 全通信服务「回馈季」开启

Dependencies tool to view exe and DLL dependencies

Deep learning compiler understanding

电子元器件行业在线采购系统精准匹配采购需求,撬动电子产业数字化发展

PC wechat multi open

What if icloud photos cannot be uploaded or synchronized?

Volcano engine was selected into the first "panorama of edge computing industry" in China

mysql for update 死锁问题排查

LeetCode之合并二叉树

煤炭行业数智化供应商管理系统解决方案:数据驱动,供应商智慧平台助力企业降本增效
随机推荐
Dlib库实现人脸关键点检测(Opencv实现)
这里数据过滤支持啥样的sql语句
使用excel快速生成sql语句
删除排序链表中的重复元素 II[链表节点统一操作--dummyHead]
Tide - 基于 async-std 的 Rust-web 框架
Leader: who can use redis expired monitoring to close orders and get out of here!
「经验」我对用户增长的理解『新用户篇』
Hospital online consultation applet source code Internet hospital source code smart hospital source code
金融服务行业SaaS项目管理系统解决方案,助力企业挖掘更广阔的增长服务空间
How to use AI technology to optimize the independent station customer service system? Listen to the experts!
医疗行业企业供应链系统解决方案:实现医疗数智化供应链协同可视
Helping the ultimate experience, best practice of volcano engine edge computing
What if icloud photos cannot be uploaded or synchronized?
NEON优化2:ARM优化高频指令总结
Distributed transaction
煤炭行业数智化供应商管理系统解决方案:数据驱动,供应商智慧平台助力企业降本增效
详解单例模式
亲测flutter打包apk后大小,比较满意
挑选智能音箱时,首选“智能”还是“音质”?这篇文章给你答案
Memory Limit Exceeded