This is documented under the heading for (?aiLmsux-imsx:...)
in https://docs.python.org/3/library/re.html, as follows:
(?aiLmsux-imsx:...)
(Zero or more letters from the set a
, i
, L
, m
, s
, u
, x
, optionally followed by -
followed by one or more letters from the i
, m
, s
, x
.) The letters set or remove the corresponding flags: re.A
(ASCII-only matching), re.I
(ignore case), re.L
(locale dependent), re.M
(multi-line), re.S
(dot matches all), re.U
(Unicode matching), and re.X
(verbose), for the part of the expression. (The flags are described in Module Contents.)
Thus, (?i)
is an inline version of the flag that is otherwise set as re.I
, or re.IGNORECASE
; it makes the match case-insensitive, such that permission denied
could also be written Permission Denied
or PERMISSION DENIED
but would still be matched.