8: Regular Expressions Flashcards
regular expressions
regexes
re
docs.python.org/3/library/re.html
re.search(pattern, string, flags=0)
.
any character except a newline
*
0 or more repetitions
+
1 or more repetitions
?
0 or 1 repetition
{m}
m repetitions
{m, n}
m-n repetitions
matches the start of the string
$
matches the end of the string or just before the newline at the end of the string
[ ]
set of characters
[ ^ ]
complementing the set
\d
decimal digit
\D
not a decimal digit
\s
whitespace characters
\S
not a whitespace character
\w
word character … as well as numbers and the underscore
\W
not a word character
re.IGNORECASE
re:MULTILINE
re.DOTALL
re.match(pattern, string, flags=0)
re.fullmatch(pattern, string, flags=0)
A|B
either A or B
(…)
a group
(?:…)
non-capturing version
: =
re.sub(pattern, repl, string, count=0, flags=0)
re.split(pattern, string, maxsplit=0, flags=0)
re.findall(pattern, string, flags=0)