finds.dev← search

// the find

asweigart/humre

★ 428 · Python · NOASSERTION · updated Jun 2023

A human-readable regular expression module for Python.

Humre is a Python library that wraps regex syntax in named functions and constants, so you write `exactly(3, DIGIT)` instead of `\d{3}`. It targets developers who know what regex does but don't want to memorize or stare at dense symbol strings. The output is still a plain regex string passed to `re.compile()`, so there's no runtime overhead.

The abstraction layer is honest about what it is — it doesn't pretend to be a regex engine, just a string builder, which means you can mix Humre output with raw strings when needed. Editor tooling (autocomplete, parenthesis matching, linting) actually works on the function calls, which is a real gain over verbose mode strings. The included pattern constants like NUMBER and HEXADECIMAL_NUMBER are a practical time-saver for the patterns everyone looks up anyway. The function naming is consistent and guessable: `zero_or_more`, `one_or_more`, `between`, `at_least` — you can largely write it without reading the docs.

Last commit was June 2023 and it's still pre-1.0 with an explicitly unstable API — that's a real adoption risk for anything production. The hexagonal explosion of convenience functions (`zero_or_more_lazy_noncap_group` etc.) suggests no one had the discipline to stop generating combinations, and most of them add noise rather than clarity. The `from humre import *` recommendation is a smell — it clobbers the built-in `compile()`, and the fix is just to give functions better names, not to encourage star imports. There's no way to go the other direction (parse an existing regex string into Humre calls), so you can't use this to document legacy patterns already in your codebase.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →