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

Skip to content

Commit 7ce22d1

Browse files
committed
#16304: merge with 3.2.
2 parents d081fbb + b87f82f commit 7ce22d1

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
@@ -824,9 +824,16 @@ attributes:
824824
Match Objects
825825
-------------
826826

827-
Match objects always have a boolean value of :const:`True`. This lets you
828-
use a simple if-statement to test whether a match was found. Match objects
829-
support the following methods and attributes:
827+
Match objects always have a boolean value of ``True``.
828+
Since :meth:`~regex.match` and :meth:`~regex.search` return ``None``
829+
when there is no match, you can test whether there was a match with a simple
830+
``if`` statement::
831+
832+
match = re.search(pattern, string)
833+
if match:
834+
process(match)
835+
836+
Match objects support the following methods and attributes:
830837

831838

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

0 commit comments

Comments
 (0)