andreasvc / pyre2

Python wrapper for RE2
BSD 3-Clause "New" or "Revised" License
99 stars 33 forks source link

`re2.Match` object is not subscriptable #31

Closed JustAnotherArchivist closed 3 years ago

JustAnotherArchivist commented 3 years ago

Since Python 3.6, the re.Match object has a __getitem__ method which simply passes through to .group() and allows for accessing groups by subscripting: https://docs.python.org/3/library/re.html#re.Match.__getitem__

re2.Match currently does not support this:

>>> import re2
>>> m = re2.match('.', 'abc')
>>> m[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 're2.Match' object is not subscriptable
andreasvc commented 3 years ago

Thanks for letting me know. Pull requests welcome!

Blightwidow commented 3 years ago

Any idea when this is going to be released ? I am trying to switch to re2 for security concerns and would love to not have to refactor my codebase 🙏🏻