Skip to content

Texomy vs regular expressions

Texomy runs on regular expressions. It adds what a large regex lacks: names, types, structure, composition and tests.

Regular expressionsTexomy
ReadabilityOne dense line per format; hard to reviewNamed types and fields in YAML
OutputFlat capture groups as stringsA typed tree with offsets and typed values
ReuseCopy and paste fragmentsTypes, imports and versioned packages
VariantsAlternation inside one patternSubtypes, each with its own fields
Overlapping matchesDepends on pattern orderDefined rules: length, position, specificity, fixed text
TestsUp to youBuilt in: *.test.yml and texomy test
ExecutionRegex engineRegex 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.

regex
(?<cur1>USD|\$|EUR|€)\s?(?<amt1>\d+(?:\.\d+)?)|(?<amt2>\d+(?:\.\d+)?)\s?(?<cur2>USD|\$|EUR|€)
money.yml
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