1. Regular expressions
A regular is a way to describe a string or character by combining symbols with special meanings.
2. Common regular matching patterns
Import re
Print(Re.findall ('\w','Hello_ | Egon 123'))#Match alphanumeric underlinePrint(Re.findall ('\w','Hello_ | Egon 123'))#match with small w non-numeric character underlinePrint(Re.findall ('\s','Hello_ | Egon 123 \ t'))#match any blank character such as [\t,\n,\r,\f]Print(Re.findall ('\s','Hello_ | Egon 123 \ t'))#match with small s to any of the whitespace characters in the opposite directionPrint(Re.findall ('\d','Hello_ | Egon 123 \ t'))#match any numberPrint(Re.findall ('\d','Hello_ | Egon 123 \ t'))#match any non-numericPrint(Re.findall ('h','hello_ | Hello h egon 123 \ t'))#Match characterPrint(Re.findall ('\ahe','hello_ | Hello h egon 123 \ t'))#match the beginning of the string with the ^Print(Re.findall ('^he','hello_ | Hello h egon 123 \ t'))## Print (Re.findall (' 123\z ', ' hello_ | Hello h egon 123 \ n \t123 ')) #匹配字符串的结尾, there is a newline, which matches only the end string before the line break. Print(Re.findall ('123\z','hello_ | Hello h egon 123 \ \t123'))#match string ends equal to $Print(Re.findall ('123$','hello_ | Hello h egon 123 \ \t123'))Print(Re.findall ('\ n','hello_ | Hello h egon 123 \ \t123'))#match a line breakPrint(Re.findall ('\ t','hello_ | Hello h egon 123 \ \t123'))#Match a tab
Python Regular expression----RE module