当前位置:网站首页>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 .
边栏推荐
猜你喜欢

Zibll子比主题V6.4.1wordpress 开心版源码下载_破解原版/直接使用/无需教程

Who doesn't want a blog site of their own - build a blog site WordPress

Installation and initialization of MariaDB database

Dynamic programming -- gliding wing of the strange thief Kidd

Summary of redis learning notes (I)
![[GPU] basic operation](/img/76/6b22368e3addd30aef1dd2258ee49a.jpg)
[GPU] basic operation

谁不想要一个自己的博客网站呢 - 搭建博客网站wordpress

DXP copper laying settings

我做功能测试这么多年的心得

SparseArray
随机推荐
CompletableFuture从了解到精通,你想知道的这里都有
从底层结构开始学习FPGA----RAM IP核及关键参数介绍
[GPU] basic operation of GPU (I)
880. decoded string at index
观察者模式、状态模式在实际工作中的使用
Redux source code implementation
Go common judgments
Problems related to pinduoduo store search, why can't new products be found on the shelves
Lantern Festival | maoqiu technology and everyone "guess riddles and have a good night"
文件操作IO-Part1
Configure the user to log in to the device through telnet -- AAA local authentication
Summary of 2 billion redis data migration
MySQL summary
At the age of 32, I fell into a middle-aged crisis and finally quit naked...
SHELL
Es6数组
Zibll sub theme v6.4.1wordpress open source download_ Crack the original / use it directly / no tutorial required
Develop stylelint rules from zero (plug-ins)
[openstack]-01- basic introduction
MySQL数据库用户管理