Metadata-Version: 2.4
Name: pyrematch
Version: 1.2.0
Summary: Python bindings for REmatch, an information extraction focused regex library that uses constant delay algorithms
Keywords: regex,rematch,regular expression,information extraction,text search,pattern matching
Author-Email: Vicente Calisto <vecalisto@uc.cl>, =?utf-8?q?Oscar_C=C3=A1rcamo?= <oscar.carcamoz@uc.cl>, =?utf-8?q?Nicol=C3=A1s_Van_Sint_Jan?= <nicovsj@uc.cl>, Gustavo Toro <gustavo.toro@uc.cl>
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Project-URL: Homepage, https://rematch.cl/
Project-URL: Repository, https://github.com/REmatchChile/REmatch
Requires-Python: >=3.9
Description-Content-Type: text/markdown


<p align="center"><img src="https://raw.githubusercontent.com/REmatchChile/REmatch-docs/refs/heads/main/rematch2.png" alt="REmatch"></p>


# PyREmatch: REmatch bindings for Python

Python bindings for REmatch, an information extraction focused regex library that uses constant delay algorithms.

* [REmatch's Official Website](https://rematch.cl/)
* [GitHub Repository](https://github.com/REmatchChile/REmatch-javascript)
* [PyREmatch Tutorial](https://github.com/REmatchChile/REmatch/wiki/pyREmatch-tutorial)


## Installation

You can install the latest release version from PyPI:

```bash
pip install pyrematch
```

Or you can build from the source code:

```bash
git clone git@github.com:REmatchChile/REmatch.git
cd REmatch
pip install .
```


## Usage

Here is an example that prints all the matches using the `finditer` function.

```python
import pyrematch as REmatch

# Define the document and the REQL pattern
document = "cperez@gmail.com\npvergara@ing.uc.cl\njuansoto@uc.cl"
pattern = r"@!domain{(\w+\.)+\w+}(\n|$)"

# Create a REQL query
query = REmatch.reql(pattern)

# Execute the query and print the results
for match in query.finditer(document):
    print(match)
```

The `Query` object contains also other useful methods. To get a single match, you can use:

```python
query.findone(document)
```

To find all the matches, you can use:

```python
query.findall(document)
```

To find a limited number of matches, you can use:

```python
limit = 10
query.findmany(document, limit)
```

To check if a match exists, you can use:

```python
query.check(document)
```

You can read more about this in the [PyREmatch Tutorial](https://github.com/REmatchChile/REmatch/wiki/pyREmatch-tutorial).
