Regex, Enhanced for Readability.
EnhEx is a simple, readable language for writing regular expressions. Write patterns like sentences. Get standard Regex output. Use it anywhere — Python, JavaScript, Rust, CLI, browser.
Regex is powerful but painfully unreadable. After a few months, even your own patterns look like alien code.
EnhEx fixes this:
- Write patterns in a clean, human-readable syntax
- Compile to standard Regex that works everywhere
- One core, written in Rust, compiled to WASM or native extension — runs identically in every language
- Rust: ✅ Native
- Python: ✅
enhexat PyPI with native extension (PyO3) - JavaScript: ✅
enhexjsat NPM with WASM (WASM BindGen)
start + one_or_more(word_char | dot | dash) + "@" + one_or_more(word_char | dash) + dot + tld() + end
^[\w\.-]+@[\w-]+\.[a-z]{2,10}$Same logic, but you can actually read the first one.
pip install enhexcargo install enhex-corenpm install enhexjspip install enhex
enhex compile "start + one_or_more(digit) + end"
# Output: ^\d+$import enhex as ex
# Compile a pattern string
pattern = ex.compile('start + one_or_more(digit) + end')
# Compile from a .enhex file
phone_pattern = ex.compile_file('phone.enhex')
# Use with standard re module
import re
if re.match(pattern, "367812009"):
print("Valid number!")import { enhex, compile, compileRegExp } from 'enhexjs';
// or compile('start + one_or_more(digit) + end'):
const pattern = enhex`start + one_or_more(digit) + end`;
const regex = new RegExp(pattern);
if (regex.test('12345')) {
console.log('Only digits!');
}
// Or automatic RegExp creation:
const re = compileRegExp('start + one_or_more(digit) + end');
if (re.test('12345')) {
console.log('Only digits!');
}use enhex_core::compile;
let pattern = compile("start + one_or_more(digit) + end").unwrap();
let re = regex::Regex::new(&pattern).unwrap();
assert!(re.is_match("12345"));# Compile a pattern string
enhex compile 'start + exactly(10, digit) + end'
# Compile a .enhex file
enhex compile phone.enhex
# Show version
enhex versionSee EnhEx Language Specification for complete syntax.
EnhEx patterns are stored in .enhex files:
email.enhex:
start + one_or_more(word_char | dot | dash) + "@" + one_or_more(word_char | dash) + "." + tld() + end
enhex/
├── core/ # Rust core engine
├── bindings/
│ ├── python/ # Python package
│ └── js/ # JavaScript/TypeScript package
├── examples/ # Example .enhex patterns
├── vscode/ # VSCode extension (coming soon)
├── playground/ # Web playground (coming soon)
├── SPEC.md # Full language specification
└── README.md
- Language specification
- Rust core engine + WASM
- Python binding
- CLI tool
- JavaScript/TypeScript binding
- VSCode extension (syntax highlighting + live preview)
- Web playground
EnhEx uses a separated versioning for core and each bindings, for example this list maybe current last versions:
core-v0.2
py-v0.5
js-v0.3.1
Rules:
- Each core version change results in the same type of version increment across all bindings. (
core-v0.4 -> core-v0.5:py-v0.6 -> py-v0.7,js-v0.5 -> js-v0.6) - Each binding can have a patch or minor version increment (the major version is only changed by the core), and this change has no effect on the core version or other bindings.
The changelog for the core and each binding is available in a separate file; see CHANGELOG.md for an overview.
MIT © Mahan Khalili
RegEx, Enhanced.