Message347997
> Are there any real world examples which show the benefit of supporting
> negative indices?
A common case is ignoring parentheses at the beginning/end, e.g.
>>> re.compile('[^,]+').findall('(foo,123,(),bar)')
['(foo', '123', '()', 'bar)']
>>> # ignore the surrounding ()
>>> re.compile('[^,]+').findall('(foo,123,(),bar)', 1, 15)
['foo', '123', '()', 'bar']
>>>
>>> # extract attributes from a tag (poc, doesn't handle all cases)
>>> re.compile('[^ ]+').findall('<input type="checkbox" id="foo" checked>', 7, 39)
['type="checkbox"', 'id="foo"', 'checked']
In both cases using -1 as endpos is simpler. |
|
Date |
User |
Action |
Args |
2019-07-16 00:36:45 | ezio.melotti | set | recipients:
+ ezio.melotti, rhettinger, tlynn, timehorse, mrabarnett, docs@python, serhiy.storchaka, anilbey |
2019-07-16 00:36:45 | ezio.melotti | set | messageid: <1563237405.05.0.879538158389.issue7940@roundup.psfhosted.org> |
2019-07-16 00:36:45 | ezio.melotti | link | issue7940 messages |
2019-07-16 00:36:44 | ezio.melotti | create | |
|