Metadata-Version: 2.4
Name: repb
Version: 0.0.3
Summary: Provides a fluent API builder for regular expressions.
Author: bronskiy
Requires-Python: >=3.7
Description-Content-Type: text/markdown

# Regular Expression Pattern Builder (repb)

**repb** is python library that allows you to create regular expression patterns using a fluent API builder. This library requires python version **3.7 or higher**.

## Features

- Create regular expression patterns with a fluent API builder.
- Build regular expression patterns into strings.
- Compile regular expression patterns into the `Pattern` class.

## How to use

```python
import re
from repb import RegexBuilder, RegexCharset, RegexGroup, GroupType

hex_digit = (RegexCharset() # charset
             .add_range("0", "9")
             .add_range("a", "f")
             .add_range("A", "F"))

pattern = (RegexBuilder() # builder
           .start() # start anchor
           .literal("#")
           .charset(hex_digit)
           .repeat(3) # quantifier
           .group(RegexGroup(GroupType.NonCapturing)
                  .charset(hex_digit)
                  .repeat(3))
           .optional() # quantifier
           .end() # end anchor
           .build())

print(pattern)  # ^\#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?$

for color in ["#FFF", "#FFFFFF", "#12G", "#FFFF"]:
    print(color, bool(re.match(pattern, color)))
# #FFF True
# #FFFFFF True
# #12G False
# #FFFF False
```

## Main Classes & Types

The main classes are:

- **`RegexBuilder`**
- `RegexCharset`
- `RegexGroup`

The main types are:

- **`GroupType`**

## Licence

repb is released as an open source project under the [MIT Licence](https://opensource.org/license/mit).
