mirror of
https://github.com/python/cpython.git
synced 2026-01-07 16:02:55 +00:00
#16304: clarify match objects docs. Initial patch by Jan Duzinkiewicz.
This commit is contained in:
parent
6d26ade920
commit
b87f82f8d4
1 changed files with 10 additions and 3 deletions
|
|
@ -814,9 +814,16 @@ attributes:
|
|||
Match Objects
|
||||
-------------
|
||||
|
||||
Match objects always have a boolean value of :const:`True`. This lets you
|
||||
use a simple if-statement to test whether a match was found. Match objects
|
||||
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:: match.expand(template)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue