Texomy vs regular expressions
Texomy runs on regular expressions. It adds what a large regex lacks: names, types, structure, composition and tests.
| Regular expressions | Texomy | |
|---|---|---|
| Readability | One dense line per format; hard to review | Named types and fields in YAML |
| Output | Flat capture groups as strings | A typed tree with offsets and typed values |
| Reuse | Copy and paste fragments | Types, imports and versioned packages |
| Variants | Alternation inside one pattern | Subtypes, each with its own fields |
| Overlapping matches | Depends on pattern order | Defined rules: length, position, specificity, fixed text |
| Tests | Up to you | Built in: *.test.yml and texomy test |
| Execution | Regex engine | Regex engine, compiled from the spec |
The same money pattern, two ways
Both match $120.50 and 40 EUR. Only one tells you what it found.
(?<cur1>USD|\$|EUR|€)\s?(?<amt1>\d+(?:\.\d+)?)|(?<amt2>\d+(?:\.\d+)?)\s?(?<cur2>USD|\$|EUR|€)Currency:
USD: [ 'USD', '\$' ]
EUR: [ 'EUR', '€' ]
Number:
Integer: '\d+'
Decimal: '\d+\.\d+'
Money:
$fields:
currency: Currency
amount: Number
$patterns:
- '#{currency}\s?#{amount}'
- '#{amount}\s?#{currency}'Same engine, a better language
Each Texomy type compiles to regular expressions, so the patterns you know still apply. What changes is how you write and maintain them: a type is named once and referenced everywhere, fields have names instead of group numbers, and the result tells you which variant matched, such as Currency::USD or Number::Decimal.
Structure, not strings
A regex returns captured strings. Texomy returns a tree: a Money node with a currency and an amount, each with its type, its exact position in the text and, where the spec asks for it, a typed value such as a date or a number.
Predictable overlaps
With alternation, whichever branch comes first wins. In Texomy, overlapping matches are resolved by defined rules: explicit order, length, position, specificity and fixed text. Declaration order only breaks the remaining ties, and Texomy can flag those as AMBIGUOUS_MATCH so you fix the spec instead of guessing.
When a plain regex is enough
- A one-off search with grep or your editor.
- A single, simple field in a stable format.
- Validation of one input value, such as an email field in a form.
Questions
Can I still use raw regex inside a spec?
Yes. Patterns are regular expressions. Texomy adds #{field} and ${Type} references on top.
More comparisons: Texomy vs LLM extraction · Texomy vs Grok patterns · Texomy vs a script from your AI
Write the spec once. Run it on everything.
Install the CLI, connect your agent, and turn your first sample into typed data in minutes.
brew install texomy/tap/texomy