@@ -257,7 +257,7 @@ matches with them.
257257Compiling Regular Expressions
258258-----------------------------
259259
260- Regular expressions are compiled into :class: ` RegexObject ` instances , which have
260+ Regular expressions are compiled into pattern objects , which have
261261methods for various operations such as searching for pattern matches or
262262performing string substitutions. ::
263263
@@ -336,7 +336,7 @@ Performing Matches
336336------------------
337337
338338Once you have an object representing a compiled regular expression, what do you
339- do with it? :class: ` RegexObject ` instances have several methods and attributes.
339+ do with it? Pattern objects have several methods and attributes.
340340Only the most significant ones will be covered here; consult the :mod: `re ` docs
341341for a complete listing.
342342
@@ -427,8 +427,8 @@ Trying these methods will soon clarify their meaning::
427427and :meth: `end ` return the starting and ending index of the match. :meth: `span `
428428returns both start and end indexes in a single tuple. Since the :meth: `match `
429429method only checks if the RE matches at the start of a string, :meth: `start `
430- will always be zero. However, the :meth: `search ` method of :class: ` RegexObject `
431- instances scans through the string, so the match may not start at zero in that
430+ will always be zero. However, the :meth: `search ` method of patterns
431+ scans through the string, so the match may not start at zero in that
432432case. ::
433433
434434 >>> print(p.match('::: message'))
@@ -450,7 +450,7 @@ in a variable, and then check if it was ``None``. This usually looks like::
450450 else:
451451 print('No match')
452452
453- Two :class: ` RegexObject ` methods return all of the matches for a pattern.
453+ Two pattern methods return all of the matches for a pattern.
454454:meth: `findall ` returns a list of matching strings::
455455
456456 >>> p = re.compile('\d+')
@@ -475,10 +475,10 @@ instances as an :term:`iterator`. [#]_ ::
475475Module-Level Functions
476476----------------------
477477
478- You don't have to create a :class: ` RegexObject ` and call its methods; the
478+ You don't have to create a pattern object and call its methods; the
479479:mod: `re ` module also provides top-level functions called :func: `match `,
480480:func: `search `, :func: `findall `, :func: `sub `, and so forth. These functions
481- take the same arguments as the corresponding :class: ` RegexObject ` method, with
481+ take the same arguments as the corresponding pattern method, with
482482the RE string added as the first argument, and still return either ``None `` or a
483483:class: `MatchObject ` instance. ::
484484
@@ -487,12 +487,12 @@ the RE string added as the first argument, and still return either ``None`` or a
487487 >>> re.match(r'From\s+', 'From amk Thu May 14 19:12:10 1998')
488488 <re.MatchObject instance at 80c5978>
489489
490- Under the hood, these functions simply produce a :class: ` RegexObject ` for you
490+ Under the hood, these functions simply create a pattern object for you
491491and call the appropriate method on it. They also store the compiled object in a
492492cache, so future calls using the same RE are faster.
493493
494494Should you use these module-level functions, or should you get the
495- :class: ` RegexObject ` and call its methods yourself? That choice depends on how
495+ pattern and call its methods yourself? That choice depends on how
496496frequently the RE will be used, and on your personal coding style. If the RE is
497497being used at only one point in the code, then the module functions are probably
498498more convenient. If a program contains a lot of regular expressions, or re-uses
@@ -1031,7 +1031,7 @@ Modifying Strings
10311031
10321032Up to this point, we've simply performed searches against a static string.
10331033Regular expressions are also commonly used to modify strings in various ways,
1034- using the following :class: ` RegexObject ` methods:
1034+ using the following pattern methods:
10351035
10361036+------------------+-----------------------------------------------+
10371037| Method/Attribute | Purpose |
@@ -1051,7 +1051,7 @@ using the following :class:`RegexObject` methods:
10511051Splitting Strings
10521052-----------------
10531053
1054- The :meth: `split ` method of a :class: ` RegexObject ` splits a string apart
1054+ The :meth: `split ` method of a pattern splits a string apart
10551055wherever the RE matches, returning a list of the pieces. It's similar to the
10561056:meth: `split ` method of strings but provides much more generality in the
10571057delimiters that you can split by; :meth: `split ` only supports splitting by
@@ -1196,10 +1196,10 @@ hexadecimal::
11961196 'Call 0xffd2 for printing, 0xc000 for user code.'
11971197
11981198When using the module-level :func: `re.sub ` function, the pattern is passed as
1199- the first argument. The pattern may be a string or a :class: ` RegexObject ` ; if
1199+ the first argument. The pattern may be provided as an object or as a string ; if
12001200you need to specify regular expression flags, you must either use a
1201- :class: ` RegexObject ` as the first parameter, or use embedded modifiers in the
1202- pattern, e.g. ``sub("(?i)b+", "x", "bbbb BBBB") `` returns ``'x x' ``.
1201+ pattern object as the first parameter, or use embedded modifiers in the
1202+ pattern string , e.g. ``sub("(?i)b+", "x", "bbbb BBBB") `` returns ``'x x' ``.
12031203
12041204
12051205Common Problems
0 commit comments