Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b87f82f

Browse files
committed
#16304: clarify match objects docs. Initial patch by Jan Duzinkiewicz.
1 parent 6d26ade commit b87f82f

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

Doc/library/re.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,9 +814,16 @@ attributes:
814814
Match Objects
815815
-------------
816816

817-
Match objects always have a boolean value of :const:`True`. This lets you
818-
use a simple if-statement to test whether a match was found. Match objects
819-
support the following methods and attributes:
817+
Match objects always have a boolean value of ``True``.
818+
Since :meth:`~regex.match` and :meth:`~regex.search` return ``None``
819+
when there is no match, you can test whether there was a match with a simple
820+
``if`` statement::
821+
822+
match = re.search(pattern, string)
823+
if match:
824+
process(match)
825+
826+
Match objects support the following methods and attributes:
820827

821828

822829
.. method:: match.expand(template)

0 commit comments

Comments
 (0)