当前位置:网站首页>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')
边栏推荐
- Summary of data analysis steps
- SQL common syntax records
- 场景化面试:关于分布式锁的十问十答
- js常用方法封装
- Modifiers of attributes of TS public, private, protect
- Utils/index TS tool function
- 递归查询多级菜单数据
- Pytorch实战——MNIST数据集手写数字识别
- The primary key is set after the table is created, but auto increment is not set
- SYSTEMd resolved enable debug log
猜你喜欢
事项研发工作流全面优化|Erda 2.2 版本如“七”而至
Some common processing problems of structural equation model Amos software
Clion-MinGW编译后的exe文件添加ico图标
Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
MQ----activeMq
Cross end solution to improve development efficiency rapidly
What should I do to prepare for the interview algorithm position during school recruitment?
Teach yourself to train pytorch model to Caffe (2)
Uni app Bluetooth communication
MySQL 千万数据量深分页优化, 拒绝线上故障!
随机推荐
办公遇到的问题--
秋招将临 如何准备算法面试、回答算法面试题
Chapter 05_ Storage engine
Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
张丽俊:穿透不确定性要靠四个“不变”
SQL knowledge leak detection
Zhang Lijun: la pénétration de l’incertitude dépend de quatre « invariants»
Determine the best implementation of horizontal and vertical screens
1.2 download and installation of the help software rstudio
Sorting out the problems encountered in MySQL built by pycharm connecting virtual machines
Talk about my fate with some programming languages
Learning notes of statistical learning methods -- Chapter 1 Introduction to statistical learning methods
Learning robots have no way to start? Let me show you the current hot research directions of robots
How to prepare for the algorithm interview and answer the algorithm interview questions
力扣------经营摩天轮的最大利润
int GetMonth( ) const throw( ); What does throw () mean?
123456
递归查询多级菜单数据
Sequence alignment
SQL common syntax records