Level 102 Level 104
Level 103

RegEx: Flags


63 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

Ignore?
re.search(pattern, string, flags=0)
searches for first occurrence of RE pattern within string with optional flags
Matching Versus Searching match
checks for a match only at the beginning of the string,
Matching Versus Searching search
checks for a match anywhere in the string
re.sub(pattern, repl, string, max=0)
replaces all occurrences of the RE pattern in string with repl, substituting all occurrences unless max provided
'^'
Matches beginning of line. Workaround: precede answ with "z ". (Don't use the quotes). Press cr to check.
$
Matches end of line. Workaround: precede answ with "z ". (Don't use the quotes). Press cr to check.
.
Matches any single character except newline. Using m option allows it to match newline as well. Workaround: precede answ with "z ". (Don't use the quotes). Press cr to check.
[...]
Matches any single character in brackets. Workaround: precede answ with "z ". (Don't use the quotes). Press cr to check.
[^...]
Matches any single character not in brackets. Workaround: precede answ with "z ". (Don't use the quotes). Press cr to check.
re*
Matches 0 or more occurrences of preceding expression.
re+
Matches 1 or more occurrence of preceding expression.
re?
Matches 0 or 1 occurrence of preceding expression.
re{ n}
Matches exactly n number of occurrences of preceding expression.
re{ n,}
Matches n or more occurrences of preceding expression.
re{ n, m}
Matches at least n and at most m occurrences of preceding expression.
a| b
Matches either a or b.
(re)
Groups regular expressions and remembers matched text. Workaround: precede answ with "z ". (Don't use the quotes). Press cr to check.
(?imx)
Temporarily toggles on i, m, or x options within a regular expression. If in parentheses, only that area is affected.
(?-imx)
Temporarily toggles off i, m, or x options within a regular expression. If in parentheses, only that area is affected.
(?: re)
Groups regular expressions without remembering matched text.
(?imx: re)
Temporarily toggles on i, m, or x options within parentheses.
(?-imx: re)
Temporarily toggles off i, m, or x options within parentheses.
(?#...)
Comment. Workaround: precede answ with "z ". (Don't use the quotes). Press cr to check.
(?= re)
Specifies position using a pattern. Doesn't have a range.
(?! re)
Specifies position using pattern negation. Doesn't have a range.
(?> re)
Matches independent pattern without backtracking.
\w
Matches word characters.
\W
Matches nonword characters.
\s
Matches whitespace. Equivalent to [\t\n\r\f].
\S
Matches nonwhitespace.
\d
Matches digits. Equivalent to [0-9].
\D
Matches nondigits.
\A
Matches beginning of string.
\Z
Matches end of string. If a newline exists, it matches just before newline.
\z
Matches end of string.
\G
Matches point where last match finished.
\b
Matches word boundaries when outside brackets. Matches backspace (0x08) when inside brackets.
\B
Matches nonword boundaries.
\n, \t
Matches newlines, carriage returns, tabs, etc.
\1...\9
Matches nth grouped subexpression.
\10
Matches nth grouped subexpression if it matched already. Otherwise refers to the octal representation of a character code.
[Pp]ython
Match "Python" or "python"
rub[ye]
Match "ruby" or "rube"
[aeiou]
Match any one lowercase vowel
[0-9]
Match any digit; same as [0123456789]
[a-z]
Match any lowercase ASCII letter
[A-Z]
Match any uppercase ASCII letter
[a-zA-Z0-9]
Match any of the above
[^aeiou]
Match anything other than a lowercase vowel
[^0-9]
Match anything other than a digit
.
Match any character except newline. Workaround: precede answ with "z ". (Don't use the quotes). Press cr to check.
\d
Match a digit: [0-9]
\D
Match a nondigit: [^0-9]
\s
Match a whitespace character: [ \t\r\n\f]
\S
Match nonwhitespace: [^ \t\r\n\f]
\w
Match a single word character: [A-Za-z0-9_]
\W
Match a nonword character: [^A-Za-z0-9_]
ruby?
Match "rub" or "ruby": the y is optional
ruby*
Match "rub" plus 0 or more ys
ruby+
Match "rub" plus 1 or more ys
\d{3}
Match exactly 3 digits
\d{3,}
Match 3 or more digits
\d{3,5}
Match 3, 4, or 5 digits