Ogex, the regex we deserved
- Rust 94.6%
- Python 3.1%
- HTML 1%
- TypeScript 0.6%
- JavaScript 0.4%
- Other 0.3%
|
|
||
|---|---|---|
| .githooks | ||
| .github | ||
| ogex | ||
| ogex-cli | ||
| ogex-python | ||
| .gitignore | ||
| Cargo.toml | ||
| LICENSE | ||
| MIGRATION.md | ||
| README.md | ||
| test_ogex.html | ||
| test_ogex.py | ||
| test_ogex.ts | ||
| test_ogex_node.mjs | ||
Ogex
A custom regex engine with unified syntax for named groups and backreferences.
Overview
Ogex introduces a cleaner, more intuitive syntax for named capturing groups and backreferences:
- Named groups:
(name:pattern)instead of(?<name>pattern) - Backreferences:
\g{name}or\g{1}instead of\k<name>or\1 - Works identically in patterns and replacement strings
The engine is written in Rust for performance and provides bindings for multiple languages.
Important
This project is going to soon be moved to a self-hosted Forgejo instance Currently it will act as a push-mirror, and in the future, github will be the push-mirror The repository is already available at: https://hangar.nixthedev.ru/NiXTheDev/Ogex
Crates
| Crate | Description |
|---|---|
| ogex | Core regex library (Rust) |
| ogex-cli | CLI tool |
| ogex-python | Python bindings |
Quick Start
Rust
See ogex/README.md
JavaScript/WASM
import { Regex } from '@ogex/ogex';
const regex = new Regex('(name:hello)');
const match = regex.find('hello world');
console.log(match.text); // "hello"
Python
import ogex
regex = ogex.Regex(r"(name:\w+) is \g{name}")
match = regex.search("John is John")
print(match.named_group("name")) # "John"
CLI
# Test a pattern
ogex test "(name:hello)" "hello world"
# Convert syntax
ogex convert "(name:abc)"
# Output: (?<name>abc)
License
- ogex: MPL-2.0
- ogex-cli: MIT