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

Skip to content

Commit 5ec6fdb

Browse files
committed
Closes #14342: remove out-of-date section about avoiding recursion errors.
1 parent 12c3cd7 commit 5ec6fdb

1 file changed

Lines changed: 0 additions & 22 deletions

File tree

Doc/library/re.rst

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,28 +1090,6 @@ The equivalent regular expression would be ::
10901090
(\S+) - (\d+) errors, (\d+) warnings
10911091

10921092

1093-
Avoiding recursion
1094-
^^^^^^^^^^^^^^^^^^
1095-
1096-
If you create regular expressions that require the engine to perform a lot of
1097-
recursion, you may encounter a :exc:`RuntimeError` exception with the message
1098-
``maximum recursion limit exceeded``. For example, ::
1099-
1100-
>>> s = 'Begin ' + 1000*'a very long string ' + 'end'
1101-
>>> re.match('Begin (\w| )*? end', s).end()
1102-
Traceback (most recent call last):
1103-
File "<stdin>", line 1, in ?
1104-
File "/usr/local/lib/python3.2/re.py", line 132, in match
1105-
return _compile(pattern, flags).match(string)
1106-
RuntimeError: maximum recursion limit exceeded
1107-
1108-
You can often restructure your regular expression to avoid recursion.
1109-
1110-
Simple uses of the ``*?`` pattern are special-cased to avoid recursion. Thus,
1111-
the above regular expression can avoid recursion by being recast as ``Begin
1112-
[a-zA-Z0-9_ ]*?end``. As a further benefit, such regular expressions will run
1113-
faster than their recursive equivalents.
1114-
11151093
.. _search-vs-match:
11161094

11171095
search() vs. match()

0 commit comments

Comments
 (0)