1/23
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
'.'
Matches any character except newline
'^'
Matches the start of a string
'$'
Matches the end of a string
'*'
Matches 0 or more repetitions of the preceding regex (as many as possible)
'+'
Matches 1 or more repetitions of the preceding regex
'?'
Matches 0 or 1 repetitions of the preceding regex
{m}
Specifies that exactly m copies of the previous RE should be matched. Fewer matches causes the entire RE not to match.
a{6} will match exactly six 'a' characters, but not five
{m, n}
Causes the resulting RE to match from m to n repetitions of the preceding RE, attempting to match as many as possible.
'\'
Either escapes special characters
Or Signals a special sequence
[ ]
Used to indicate a set of characters
[amk] will match 'a', 'm', or 'k'
[0-5][0-9] will match all two digit numbers from 00 - 59
[a-z] any single letter
[(+*)] special characters lose special meaning
Character classes are also accepted e.g. \w or \S
^ for characters not in a set e.g., [^5] will match any character except 5
'|'
OR
A|B creates regex that will match either A or B
(...)
Matches whatever regex is inside the parenthesis and indicates the start and end of a group
(?...)
Extension notation. First character after the '?' determines what the meaning and further syntax of the construct is.
\number
Matches the contents of the group of some number. Groups are numbered starting from 1.
e.g., re.findall(r'(a)', 'aaa')
\1 , \2, \3
\A
Matches only at the start of the string
\b
Matches the empty string, but only at the beginning or end of a word.
r'\bfoo\b' matches 'foo', 'foo.', '(foo)', 'bar foo baz' but not 'foobar' or 'foo3'.
\B
Matches the empty string, but only when it is not at the beginning or end of a word. This means r'py\B' matches 'python', 'py3', 'py2' but not 'py', 'py.' or 'py!'
\d
Matches any decimal digit
\D
Matches any character which is nota a Unicode digit. Opposite of \d
\s
Matches whitespace characters
\S
Matches any character which is not a whitespace character
\w
Matches words (can include numbers)
\W
Matches any character which is not a Unicode word character
\Z
Matches only at the end of a string