But outside of the loop because of the internal buffering mechanism. The efficiency of the two is not bad up and down.
------------------------- ------------------------- ------------------------- ------------------------- ------------------------- -------------------------
3.5. Compile flags
Compiling flags allows you to change the way you work in some ways. The compile flag has two available names in the RE module: full name and shorthand. For example, the shorthand for ignorecase is the letter I (assuming that you are familiar with the Perl language pattern, you will know that the Perl language shorthand is the same as this, for example, re.) Verbose and shorthand are re.x).
Multiple compilation flags can be either logical or connected. For example, re. I | Re. M set I and M two flags.
I
IGNORECASE
Matches do not distinguish between uppercase and lowercase, so that character classes and text strings do not differentiate between uppercase and lowercase when matching characters. For example, [A-z] will also match lowercase letters. Spam will match spam, spam, and spam. If you do not set the locale flag, you do not consider the issue of the language (locale) setting method.
L
LOCALE
Making \w, \w, \b, and \b depend on the current locale, not the Unicode database.
Locale is a function of the C language library, mainly to consider the differences in language when typing code. Suppose, for example, that you are working on a French text. You want to write \w+ to match the words. But \w only matches the words in today's character class [A-za-z], it doesn't match ' é ' or '? ', assuming your system is set to the French locale, then the C function will think ' é ' is also a letter. The locale flag is set when compiling the normal table. \w will be able to recognize the French. But it's relatively slow.
M
MULTILINE
(^ and $ we haven't mentioned yet.) They will be explained later)
Normally, ^ matches only the beginning of a string, and $ only matches the end of the string, and when this flag is set, the meta-character ^ will match the beginning of each line in the string, and, similarly, the meta-character $ will match the end of each line.
S
Dotall
Make the dot '. ' Matches all of the characters. Contains a newline character.
Assuming this flag is not set, dot '. ' All characters except the line break will be matched.
A
Ascii
Causes the \w, \w, \b, \b, and \s values to match ASCII characters instead of Unicode characters. This flag is only meaningful for Unicode mode, and ignores byte patterns.
X
VERBOSE
This flag allows you to organize the form to be more flexible. Thus the written form of the expression is more readable. Assuming that this flag is set, the spaces in the form are ignored, but the spaces in the character class are not included. It also does not contain spaces that are escaped by backslashes, which will allow you to organize your regular expressions more clearly.
Other than that. This flag also agrees to use gaze in the regular form, and the character # and subsequent characters will be ignored by the regex, unless the pound # is escaped in the character class or after a backslash.
Here's a look at one using re. Examples of verbose:
>>> charref = re.compile (R ' &[#] #開始数字引用 (0[0-7]+ #八进制格式 |[ 0-9]+ #十进制格式 |x[0-9a-fa-f]+ #十六进制格式); #结尾分号 ", Re. VERBOSE)
Suppose you don't have to verbose settings. This form will be the following format:
>>> charref = Re.compile (' &[#] (0[0-7]+ ' |[ 0-9]+ ' |x[0-9a-fa-f]+);
in the examples above. We used Python's ability to concatenate strings on its own initiative, dividing the regular form into a few smaller parts. But it still does not use re. Verbose version number of re good understanding.
python--(2)