Metadata-Version: 2.4
Name: ebr
Version: 1.0.1
Summary: EBR (Easy Bracket Regex) - Simplified regex with bracket notation
Home-page: https://github.com/Qarvexium/ebr
Author: Qarvexium
Author-email: 
License: MIT
Project-URL: Homepage, https://github.com/Qarvexium/ebr
Project-URL: Documentation, https://github.com/Qarvexium/ebr#readme
Project-URL: Repository, https://github.com/Qarvexium/ebr
Project-URL: Bug Tracker, https://github.com/Qarvexium/ebr/issues
Keywords: regex,pattern-matching,text-processing,ebr,bracket-notation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: C++
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# EBR - Easy Bracket Regex

[![PyPI version](https://badge.fury.io/py/ebr.svg)](https://badge.fury.io/py/ebr)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

EBR (Easy Bracket Regex) is a simplified pattern matching library that makes text extraction intuitive and readable. Instead of complex regex syntax, use simple bracket notation.

## Features

- **`<|cap|>`** - Capture text between patterns
- **`<|ow|>`** - Match optional whitespace (zero or more spaces)
- **`<|any|>`** - Match any single character
- **`<|esc|X>`** - Match a specific character X literally

## Installation

```bash
pip install ebr
```

## Quick Start

```python
from ebr import ebr, capture, capture_all

# Single capture
text = "Hello how are you"
result = ebr(text, "Hello how <|cap|> you")
print(result)  # Output: "are"

# Multiple captures
text = "Hello how are yall"
results = ebr(text, "<|cap|> how <|cap|>")
print(results)  # Output: ['Hello', 'are yall']

# Optional whitespace
text = "Hello            World"
result = capture(text, "Hello<|ow|><|cap|>")
print(result)  # Output: "World"

# Any character wildcard
text = "Hello:World"
result = capture(text, "Hello<|any|><|cap|>")
print(result)  # Output: "World"

# Escape special characters
text = "Hello*World"
result = capture(text, "Hello<|esc|*><|cap|>")
print(result)  # Output: "World"
```

## API Reference

### `ebr(text: str, pattern: str) -> Union[str, List[str]]`

Smart function that returns a single string for one capture group, or a list for multiple capture groups.

### `capture(text: str, pattern: str) -> str`

Extracts the first capture group from text. Returns empty string if no match.

### `capture_all(text: str, pattern: str) -> List[str]`

Extracts all capture groups from text. Returns empty list if no match.

## Pattern Syntax

| Pattern | Description | Regex Equivalent |
|---------|-------------|------------------|
| `<|cap|>` | Capture group (greedy for last occurrence, non-greedy otherwise) | `(.+?)` or `(.+)` |
| `<|ow|>` | Optional whitespace | `\s*` |
| `<|any|>` | Any single character | `.` |
| `<|esc|X>` | Literal character X | `\X` |

## Examples

### Extract data from structured text

```python
from ebr import capture_all

log = "2024-01-15 10:30:45 ERROR User login failed"
parts = capture_all(log, "<|cap|> <|cap|> <|cap|> <|cap|>")
date, time, level, message = parts
print(f"Level: {level}, Message: {message}")
```

### Parse key-value pairs

```python
from ebr import capture

config = "timeout=30"
value = capture(config, "timeout<|ow|>=<|ow|><|cap|>")
print(f"Timeout: {value}")  # Output: "Timeout: 30"
```

### Handle flexible spacing

```python
from ebr import capture

text1 = "HelloWorld"
text2 = "Hello World"
text3 = "Hello            World"

pattern = "Hello<|ow|><|cap|>"
print(capture(text1, pattern))  # Output: "World"
print(capture(text2, pattern))  # Output: "World"
print(capture(text3, pattern))  # Output: "World"
```

## Why EBR?

Traditional regex can be hard to read and write:
```python
import re
result = re.search(r"Hello how (.+?) you", text).group(1)
```

EBR makes it intuitive:
```python
result = ebr(text, "Hello how <|cap|> you")
```

## Requirements

- Python 3.7+
- C++17 compatible compiler
- setuptools

## License

MIT License - see LICENSE file for details
