1[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/asottile.onigurumacffi?branchName=master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=61&branchName=master)
2[![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/asottile/asottile/61/master.svg)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=61&branchName=master)
3
4onigurumacffi
5=============
6
7python cffi bindings for the oniguruma regex engine
8
9### installation
10
11```bash
12pip install onigurumacffi
13```
14
15- wheels should be available on pypi in most cases
16- to build from source, `libonig-dev` must be installed prior to installation
17
18### api
19
20the api is currently *very limited* (basically just enough to support what I
21needed).
22
23#### `compile(pattern: str) -> _Pattern`
24
25make a compiled pattern
26
27#### `compile_regset(*patterns: str) -> _RegSet`
28
29make a compiled RegSet
30
31#### `OnigSearchOption`
32
33an enum listing the search-time options for oniguruma
34
35the current set of options are:
36
37```python
38class OnigSearchOption(enum.IntEnum):
39    NONE = ...
40    NOTBOL = ...
41    NOTEOL = ...
42    POSIX_REGION = ...
43    CHECK_VALIDITY_OF_STRING = ...
44    NOT_BEGIN_STRING = ...
45    NOT_BEGIN_POSITION = ...
46```
47
48#### `_Pattern.match(s: str, start: int = 0, flags: OnigSearchOption = OnigSearchOption.NONE) -> Optional[_Match]`
49
50match a string using the pattern.  optionally set `start` to adjust the offset
51which is searched from
52
53#### `_Pattern.search(s: str, start: int = 0, flags: OnigSearchOption = OnigSearchOption.NONE) -> Optional[_Match]`
54
55search a string using the pattern.  optionally set `start` to adjust the offset
56which is searched from
57
58#### `_Pattern.number_of_captures() -> int`
59
60return the number of captures in the regex
61
62#### `_RegSet.search(s: str, start: int = 0, flags: OnigSearchOption = OnigSearchOption.NONE) -> Tuple[int, Optional[_Match]]`
63
64search a string using the RegSet.  optionally set `start` to adjust the offset
65which is searched from
66
67the leftmost regex index and match is returned or `(-1, None)` if there is no
68match
69
70#### `_Match.group(n: int = 0) -> str`
71
72return the string of the matched group, defaults to 0 (the whole match)
73
74#### `_Match[n: int] -> str`
75
76a shorthand alias for `_Match.group(...)`
77
78#### `_Match.start(n: int = 0) -> int`
79
80return the character position of the start of the matched group, defaults to 0
81(the whole match)
82
83#### `_Match.end(n: int = 0) -> int`
84
85return the character position of the end of the matched group, defaults to 0
86(the whole match)
87
88#### `_Match.span(n: int = 0) -> int`
89
90return `(start, end)` character position of the matched group, defaults to 0
91(the whole match)
92
93#### `_Match.expand(s: str) -> str`
94
95expand numeric groups in `s` via the groups in the match
96