File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
11171095search() vs. match()
You can’t perform that action at this time.
0 commit comments