Intro to Regular Expression

"Basic Introduction"

Posted by Mugen on May 9, 2020

It took longer than expected.

re — Regular expression operations

Python3 - Regular Expression HOWTO

正则表达式30分钟入门教程

What does the “r” in pythons re.compile(r’ pattern flags’) mean?:

the r string prefix is not specifically related to regex’s, but to strings generally in Python.

Normal strings use the backslash character as an escape character for special characters (like newlines):

1
2
3
print('this is \n a test')
this is 
 a test

The r prefix tells the interpreter not to do this:

1
2
print(r'this is \n a test')
this is \n a test

python re.match与re.search的区别

re.match只匹配字符串的开始,如果字符串开始不符合正则表达式,则匹配失败,函数返回None;而re.search匹配整个字符串,直到找到一个匹配。

PYTHON的RE模块理解(RE.COMPILE、RE.MATCH、RE.SEARCH)

这个里面例子挺多的

正则—re模块的基础用法(re.match() /单个字符匹配/ 多个字符匹配)