diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-04 04:59:51 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-04 04:59:51 (GMT) |
commit | 7ce22d19403873d590bdda78b721e15510132d16 (patch) | |
tree | 886d45626dc1295ea8e8273c00e3b9b6ca7a5d65 | |
parent | d081fbba58882adc06a07f820ecf555a992e8966 (diff) | |
parent | b87f82f8d46c8cd0fd4ab60f9680ca51ad3345bc (diff) | |
download | cpython-7ce22d19403873d590bdda78b721e15510132d16.zip cpython-7ce22d19403873d590bdda78b721e15510132d16.tar.gz cpython-7ce22d19403873d590bdda78b721e15510132d16.tar.bz2 |
#16304: merge with 3.2.
-rw-r--r-- | Doc/library/re.rst | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst index 07623c9..b0cb870 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -824,9 +824,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) |