当前位置:网站首页>01. regular expression overview
01. regular expression overview
2022-06-30 06:10:00 【Jiangshuaishuai】
List of articles
1. Overview of regular expressions
Regular expressions , It's actually a 「 Regular expressions 」, We set the rules , You can match the desired data from a string .
stay Wikipedia On , We see 「 Regular expressions 」 The description is as follows :
Regular expressions ( English :Regular Expression, Often abbreviated to regex、regexp or RE), also called Regular expressions 、 Regular representation 、 Regular expressions 、 Conventional representation , It's a concept of computer science . Regular expressions are described using a single string 、 Match a string that matches a syntax rule . In many text editors , Regular expressions are often used for retrieval 、 Replace the text that matches a pattern .
Many programming languages support string manipulation with regular expressions . for example , stay Perl A powerful regular expression engine is built in . The concept of regular expression was originally developed by Unix Tool software in ( for example sed and grep) Popular .
And more simply to understand , In fact, that is 「 Take a mold , Get the data you want 」.
in addition , Regular expressions are an indispensable technique in programming , Especially now people like to use Python To implement a web crawler , But also can realize its powerful and charm .
2. Common cases ( cell-phone number 、 Email verification )
like , When you log on to a website , An account can be a mailbox , It can also be a mobile phone number . here , The system will always check whether the format of your email or mobile number is correct , Then judge whether there is this user in the system .


If the format you entered is incorrect , The system will prompt , How does it match and validate the information you enter ?
such as , The format of the mobile number matches , Including Chinatelecom 、 China Unicom 、 China Mobile 、 China Radio and television 、 Wireless network card 、 Virtual operators, etc , Our regular expressions can be written like this :
/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
also , The format of the mailbox matches , Just keep it simple :
/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/
I can't understand it now , It doesn't matter , More complicated content , We will open them one by one and introduce them to you in detail , I can understand it right away , Very simple .
边栏推荐
- InputStream转InputStreamSource
- To: k210 realizes face recognition (code interpretation attached)
- Verilog中case,casez,casex语句的用法
- Is it safe to open an account online? Can you open an account to speculate on the Internet?
- ES6数组遍历与ES5数组遍历
- MySQL storage system
- Base64详解:玩转图片Base64编码
- ES6解构赋值
- One sentence introduction to Trojan horse
- Leetcode search insert location
猜你喜欢
随机推荐
[MD editing required] welcome to the CSDN markdown editor
ES6箭头函数
CompletableFuture从了解到精通,你想知道的这里都有
requests. The difference between session () sending requests and using requests to send requests directly
Voting vault: a new primitive for defi and Governance
MySQL事物
ES6 array
UE4_ Editor development: highlight the UI making method according to the assets dragged by the mouse (1)
RSA and AES
STM32F103系列控制的OLED IIC 4针
Leetcode search insert location
Base64详解:玩转图片Base64编码
inno setup 最简单的自定义界面效果
PHP knowledge points
Luogup2756 pilot pairing scheme problem (maximum flow)
旋转标注工具roLabelImg
File operation io-part1
Use and principle of completionservice (source code analysis)
Intelligent question - horse racing question
反編譯正常回編譯出現問題自己解决辦法









