python.org. re
Вот инфа про вопросы
(?...)
This is an extension notation (a '?' following a '(' is not meaningful otherwise). The first character after the '?' determines what the meaning and further syntax of the construct is. Extensions usually do not create a new group; (?P<name>...) is the only exception to this rule. Following are the currently supported extensions.
Вот инфа про двоеточие
(?:...)
A non-capturing version of regular parentheses. Matches whatever regular expression is inside the parentheses, but the substring matched by the group cannot be retrieved after performing a match or referenced later in the pattern.
Вопросы означают расширения регулярных выражений. Двоеточие - это такое расширение, когда группа делается невидимой в результате. То есть совпадение с ней будет, но она не будет добавлена к результатам.
Вот пример, где используется расширение с двоеточием
>>> import re >>> >>> match = re.search(r'(..)(..)(..)', 'abcdef') >>> match.groups() ('ab', 'cd', 'ef') >>> >>> match = re.search(r'(..)(?:..)(..)', 'abcdef') >>> match.groups() ('ab', 'ef') >>>