google-re2

RE2 Python bindings

26 个版本 Python ~=3.9
The RE2 Authors <re2-dev@googlegroups.com>
安装
pip install google-re2
poetry add google-re2
pipenv install google-re2
conda install google-re2
描述

A drop-in replacement for the re module.

It uses RE2 under the hood, of course, so various PCRE features (e.g. backreferences, look-around assertions) are not supported. See https://github.com/google/re2/wiki/Syntax for the canonical reference, but known syntactic "gotchas" relative to Python are:

  • PCRE supports \Z and \z; RE2 supports \z; Python supports \z, but calls it \Z. You must rewrite \Z to \z in pattern strings.

Known differences between this module's API and the re module's API:

  • The error class does not provide any error information as attributes.
  • The Options class replaces the re module's flags with RE2's options as gettable/settable properties. Please see re2.h for their documentation.
  • The pattern string and the input string do not have to be the same type. Any str will be encoded to UTF-8.
  • The pattern string cannot be str if the options specify Latin-1 encoding.

Known issues with regard to building the C++ extension:

  • Building requires RE2 to be installed on your system. On Debian, for example, install the libre2-dev package.
  • Building requires pybind11 to be installed on your system OR venv. On Debian, for example, install the pybind11-dev package. For a venv, install the pybind11 package from PyPI.
  • Building on macOS is known to work, but has been known to fail. For example, the system Python may not know which compiler flags to set when building bindings for software installed by Homebrew; see https://docs.brew.sh/Homebrew-and-Python#brewed-python-modules.
  • Building on Windows has not been tested yet and will probably fail.
版本列表
1.1.20251105 2025-11-05
1.1.20250805 2025-08-05
1.1.20250722 2025-07-28
1.1.20240702 2024-07-01
1.1.20240701 2024-06-30
1.1.20240601 2024-05-31
1.1.20240501 2024-04-30
1.1 2023-07-31
1.0 2022-10-24
0.2.20220601 2022-05-31
0.2.20220401 2022-03-31
0.2.20220201 2022-01-31
0.2.20211101 2021-11-01
0.2.20210901 2021-09-01
0.2.20210801 2021-08-01
0.2.20210601 2021-07-01
0.1.20210601 2021-06-01
0.1.20210401 2021-04-11
0.0.7 2020-06-23
0.0.6 2020-04-05
0.0.5 2020-04-04
0.0.4 2019-12-09
0.0.3 2019-09-26
0.0.2 2019-09-26
0.0.1 2019-09-26
0.0.0 2019-09-26