Skip to main content

python cffi bindings for the oniguruma regex engine

Project description

Build Status Azure DevOps coverage

onigurumacffi

python cffi bindings for the oniguruma regex engine

installation

pip install onigurumacffi
  • wheels should be available on pypi in most cases
  • to build from source, libonig-dev must be installed prior to installation

api

the api is currently very limited (basically just enough to support what I needed).

compile(pattern: str) -> _Pattern

make a compiled pattern

compile_regset(*patterns: str) -> _RegSet

make a compiled RegSet

OnigSearchOption

an enum listing the search-time options for oniguruma

the current set of options are:

class OnigSearchOption(enum.IntEnum):
    NONE = ...
    NOTBOL = ...
    NOTEOL = ...
    POSIX_REGION = ...
    CHECK_VALIDITY_OF_STRING = ...
    NOT_BEGIN_STRING = ...
    NOT_BEGIN_POSITION = ...

_Pattern.match(s: str, start: int = 0, flags: OnigSearchOption = OnigSearchOption.NONE) -> Optional[_Match]

match a string using the pattern. optionally set start to adjust the offset which is searched from

_Pattern.search(s: str, start: int = 0, flags: OnigSearchOption = OnigSearchOption.NONE) -> Optional[_Match]

search a string using the pattern. optionally set start to adjust the offset which is searched from

_Pattern.number_of_captures() -> int

return the number of captures in the regex

_RegSet.search(s: str, start: int = 0, flags: OnigSearchOption = OnigSearchOption.NONE) -> Tuple[int, Optional[_Match]]

search a string using the RegSet. optionally set start to adjust the offset which is searched from

the leftmost regex index and match is returned or (-1, None) if there is no match

_Match.group(n: int = 0) -> str

return the string of the matched group, defaults to 0 (the whole match)

_Match[n: int] -> str

a shorthand alias for _Match.group(...)

_Match.start(n: int = 0) -> int

return the character position of the start of the matched group, defaults to 0 (the whole match)

_Match.end(n: int = 0) -> int

return the character position of the end of the matched group, defaults to 0 (the whole match)

_Match.span(n: int = 0) -> int

return (start, end) character position of the matched group, defaults to 0 (the whole match)

_Match.expand(s: str) -> str

expand numeric groups in s via the groups in the match

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onigurumacffi-0.0.19.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distributions

onigurumacffi-0.0.19-pp36-pypy36_pp73-manylinux2010_x86_64.whl (560.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

onigurumacffi-0.0.19-cp38-cp38-win_amd64.whl (183.4 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

onigurumacffi-0.0.19-cp38-cp38-win32.whl (166.7 kB view hashes)

Uploaded CPython 3.8 Windows x86

onigurumacffi-0.0.19-cp37-cp37m-win_amd64.whl (183.4 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

onigurumacffi-0.0.19-cp37-cp37m-win32.whl (166.6 kB view hashes)

Uploaded CPython 3.7m Windows x86

onigurumacffi-0.0.19-cp36-cp36m-win_amd64.whl (183.4 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

onigurumacffi-0.0.19-cp36-cp36m-win32.whl (166.6 kB view hashes)

Uploaded CPython 3.6m Windows x86

onigurumacffi-0.0.19-cp36-abi3-manylinux1_x86_64.whl (529.8 kB view hashes)

Uploaded CPython 3.6+

onigurumacffi-0.0.19-cp36-abi3-macosx_10_14_x86_64.whl (221.9 kB view hashes)

Uploaded CPython 3.6+ macOS 10.14+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page