Ogex, the regex we deserved
- Rust 94.6%
- Python 3.1%
- HTML 1%
- TypeScript 0.6%
- JavaScript 0.4%
- Other 0.3%
* fix: add version to ogex-cli dependency, remove deprecated --no-build-hook flag * ci: publish npm under @ogex org instead of @ogex-nu - Changed wasm-pack scope from --scope ogex-nu to --scope ogex - Updated job name to reflect @ogex/ogex package - Updated PR comment to show correct npm package name |
||
|---|---|---|
| .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.
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