mirror of https://github.com/python/cpython
#16304: clarify match objects docs. Initial patch by Jan Duzinkiewicz.
This commit is contained in:
parent
93d628b378
commit
51c374dede
|
@ -797,9 +797,16 @@ Match Objects
|
|||
|
||||
.. class:: MatchObject
|
||||
|
||||
Match Objects always have a boolean value of :const:`True`, so that you can test
|
||||
whether e.g. :func:`match` resulted in a match with a simple if statement. They
|
||||
support the following methods and attributes:
|
||||
Match objects always have a boolean value of ``True``.
|
||||
Since :meth:`~regex.match` and :meth:`~regex.search` return ``None``
|
||||
when there is no match, you can test whether there was a match with a simple
|
||||
``if`` statement::
|
||||
|
||||
match = re.search(pattern, string)
|
||||
if match:
|
||||
process(match)
|
||||
|
||||
Match objects support the following methods and attributes:
|
||||
|
||||
|
||||
.. method:: MatchObject.expand(template)
|
||||
|
|
Loading…
Reference in New Issue