当前位置:网站首页>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");}
边栏推荐
- 「杂谈」对数据分析未来的几点思考
- Another CVPR 2022 paper was accused of plagiarism, and Ping An insurance researchers sued IBM Zurich team
- Glacier teacher's book
- Multipass Chinese document - setting graphical interface
- Troubleshooting MySQL for update deadlock
- 《客从何处来》
- Swin-transformer --relative positional Bias
- 基于STM32F1的环境光与微距离检测系统
- 使用excel快速生成sql语句
- 医疗行业企业供应链系统解决方案:实现医疗数智化供应链协同可视
猜你喜欢

如何利用AI技术优化独立站客服系统?听听专家怎么说!

TCP packet sticking problem

领导:谁再用 Redis 过期监听实现关闭订单,立马滚蛋!

Electronic components bidding and purchasing Mall: optimize traditional purchasing business and speed up enterprise digital upgrading

LeetCode之合并二叉树

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

OneFlow源码解析:算子签名的自动推断

Redis - persistent RDB and persistent AOF

What if icloud photos cannot be uploaded or synchronized?

LeetCode动态规划经典题(一)
随机推荐
Sword finger offer 16 Integer power of numeric value
煤炭行业数智化供应商管理系统解决方案:数据驱动,供应商智慧平台助力企业降本增效
Vulnerability recurrence ----- 38. Thinkphp5 5.0.23 Remote Code Execution Vulnerability
挑选智能音箱时,首选“智能”还是“音质”?这篇文章给你答案
Coding officially entered Tencent conference application market!
NFT挖矿游GameFi链游系统开发搭建
EasyNVR平台设备通道均在线,操作出现“网络请求失败”是什么原因?
音频 librosa 库 与 torchaudio 库中 的 Mel- spectrogram 进行对比
电子元器件招标采购商城:优化传统采购业务,提速企业数字化升级
基于STM32F1的环境光与微距离检测系统
《所谓情商高,就是会说话》读书笔记
NFT technology for gamefi chain game system development
Electronic components bidding and purchasing Mall: optimize traditional purchasing business and speed up enterprise digital upgrading
一套十万级TPS的IM综合消息系统的架构实践与思考
Techo Youth2022学年高校公开课:直播连麦的背后,探索音视频技术如何应用
Detailed single case mode
PHP uses queues to solve maze problems
Tensorflow2 ten must know for deep learning
详解单例模式
Do you really understand the persistence mechanism of redis?