当前位置:网站首页>regular expression
regular expression
2022-07-05 21:35:00 【Nuoyiyou ~】
Regular expression online verification :https://regex101.com
Regular expressions = Ordinary character + Special characters
Special characters :
.: Match any single character except line feed
*: Match the previous subexpression any number of times ( Include 0 Time )
+: Match previous subexpression one or more times
\: Escapes special characters
\d{m,n}: Match the Numbers m~n Time , Equate to [0-9]{m~n}
\D: Match non numeric characters , Equate to [^0-9]
?: As few matches as possible , Just once
\s: Match any blank character ( Space 、tab、 A newline )
\S: Match any character that is not a space character
\w: Match any text character ( Letter 、 Numbers 、 Underline )
\W: Match any non literal character ( Punctuation 、 Space )
[]: Match any one of several characters
^: Indicates the beginning of the text , Also means non
$: Indicates the end position of the text
(): Packet matching
Example 1:
Content : Salary is 10-16k*16 pay , Dongcheng District, Beijing
expression :\d+-\d+k[\*\d pay ]*
result :10-16k*16 pay
Group matching example :
import re
content = """
16788888888 my cellphone number 1111
12566666666 my cellphone number 1111
13577777777 my cellphone number 1111
"""
re = re.compile("(\d+) my cellphone number (\d+)")
def get_value():
for one in re.findall(content):
print(one)
if __name__ == '__main__':
get_value()
result :
('16788888888', '1111')
('12566666666', '1111')
('13577777777', '1111')
边栏推荐
- Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry
- kingbaseES V8R3数据安全案例之---审计记录清除案例
- 【日常训练--腾讯精选50】89. 格雷编码(看题解才会的)
- 字典树简单入门题(居然是蓝题?)
- Golang(1)|从环境准备到快速上手
- JMeter installation under win7
- Aitm2-0002 12s or 60s vertical combustion test
- 第05章_存储引擎
- Enclosed please find. Net Maui's latest learning resources
- 2.2.5 basic sentences of R language drawing
猜你喜欢
Pytorch实战——MNIST数据集手写数字识别
Pytoch practice -- MNIST dataset handwritten digit recognition
Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
JMeter installation under win7
场景化面试:关于分布式锁的十问十答
Some common processing problems of structural equation model Amos software
張麗俊:穿透不確定性要靠四個“不變”
EasyExcel的读写操作
Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
Learning robots have no way to start? Let me show you the current hot research directions of robots
随机推荐
【案例】定位的运用-淘宝轮播图
Ethereum ETH的奖励机制
Pytoch practice -- MNIST dataset handwritten digit recognition
What should I do to prepare for the interview algorithm position during school recruitment?
kingbaseES V8R3数据安全案例之---审计记录清除案例
leetcode:1755. Sum of subsequences closest to the target value
Pytorch实战——MNIST数据集手写数字识别
场景化面试:关于分布式锁的十问十答
Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
Learning robots have no way to start? Let me show you the current hot research directions of robots
Utils/index TS tool function
Objects in the list, sorted by a field
Haas506 2.0 development tutorial - Alibaba cloud OTA - PAC firmware upgrade (only supports versions above 2.2)
2022-07-03-CKA-粉丝反馈最新情况
让开发效率飞速提升的跨端方案
Postgres establish connection and delete records
Learning notes of statistical learning methods -- Chapter 1 Introduction to statistical learning methods
Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
办公遇到的问题--
Golang(1)|从环境准备到快速上手