Https://docs.python.org/3/library/re.html
Http://www.cnblogs.com/PythonHome/archive/2011/11/19/2255459.html
1. Provide regular expression-related operations
2. Pattern strings and matching strings can be Unicode or 8-bit strings, but cannot be mixed
3. Syntax
Http://www.cnblogs.com/book-book/p/5411634.html
'. ' can match ' \ n ' in Dotall mode
' ^ ', ' $ ' can match multi-line start and end in multiline mode
(? ailmsux):
A:ascii-only
I:ignore case
L:local dependent
M:multiple Line
S:dot All
U:unicode-only
X:verbose
(? P<name>, ...)
(? P=name)
(?#...)
(? <= ...)
(?<!...)
(? (id/name) Yes-pattern|no-pattern)
\a, \z Match string start and end positions
4. Module contents
Re.compile (pattern, flags=0)
Returns the Regexobject object
Flags are separated by ' | ' When there are multiple
Re. A Re. Ascii
Re. DEBUG
Re. I Re. IGNORECASE
Re. L Re. LOCAL
Re. M Re. MULTILINE
Re. S Re. Dotall
Re. X Re. VERBOSE
Re.search (Pattern, string, flags=0)
Matches anywhere in a string, returns the first match to the object (Match object), or returns none
Re.match (Pattern, string, flags=0)
Match at the start of string, even if there is a re. M property)
Re.fullmatch (Pattern, string, flags=0)
Returns the corresponding match object when the entire string can be matched by pattern, otherwise none is returned
Re.split (Pattern, String, maxsplit=0, flags=0)
Using pattern to divide a string, if pattern is enclosed in parentheses, the segmented part that can be matched by the pattern will remain in the result.
Maxsplit is not 0 o'clock, the remainder is retained in the result after splitting maxsplit times
If the beginning (or end) can be matched by pattern, the result list starts with a blank string (or ends)
Currently: Empty pattern will be ignored, and if the pattern may be empty, there is futurewarning, if the pattern is empty, there is valueerror
Re.findall (Pattern, string, flags=0)
Find all non-overlapping matching substrings and return a list
Re.finditer (Pattern, string, flags=0)
Find the matching substring and return the iterator, if no match returns an empty list
Re.sub (Pattern, Repl, String, count=0, flags=0)
Replace a string with a pattern-matched substring with REPL
Replace count times when count is not 0
REPL can be a function
RE.SUBN (Pattern, Repl, String, count=0, flags=0)
Same as Re.sub () but re.subn () returns a two-tuple containing the number of heart strings and replacement words
Re.escape (String)
To escape the non-alphanumeric character of a string
Re.purge ()
Clear the RE cache
exception
Re.error (msg, Pattern=none, Pos=none)
Regular Expression Object:
Regex.search (string[, pos[, Endpos])
Regex.match (string[, pos[, Endpos])
Regex.fullmatch (string[, pos[, Endpos])
Regex.Split (String, maxsplit=0)
Regex.findall (string[, pos[, Endpos])
Regex.finditer (string[, pos[, Endpos])
Regex.sub (Repl, String, count=0)
Regex.subn (Repl, String, count=0)
Regex.flags
Regex.groups
Regex.groupindex
Regex.pattern
Match Object:
Match.expand (template)
Match.group ([group1,...])
Match.Groups (Default=none)
Match.groupdict (Default=none)
Match.start ([group]) returns the match start position
Match.end ([group]) returns the match end position
Match.span ([group]) returns a two-tuple containing the starting end of the match
Match.pos
Match.endpos
Match.lastindex
Match.lastgroup
Match.re
Match.string
Re Modules | Python 3.5.1