Skip to content

Docs

Cookbook: Pre-Parsed Value Extraction

Regex finds candidate emails, phone numbers, and amounts; Jev picks the requested span so code copies a verbatim value that cannot be invented, with no free-text extraction required.
Format
Docs
Reading time
2 min
Published by
TypeSafe AI
Last verified
Sep 2026

Highlights

  • Jev only chooses among regex-found spans, so the returned value is copied verbatim and cannot be invented.
  • A receipt email was picked at 0.98, a cell number normalized to +14155550177, and an invoice total read as $1,315.50.
  • Amounts parse to Decimal in code, while a $50.00 courtesy credit was flagged at P(credit) 0.99.
  • find() over-finds and dedupes while pick() offers the spans as options plus a none hatch.

Quickstart

python
EMAIL_RE = re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}")

candidates = find(EMAIL_RE, EMAIL_DOC)  # regex over-finds, deduped, document order
answer = ts.system_one(
    state=EMAIL_DOC,
    questions={"pick": Choice(
        instructions="Which email address does the sender want their receipt sent to?",
        criteria={c: None for c in candidates} | {NONE: "None of these is the requested value."},
    )},
    model=TYPESAFE_MODEL,
).answers["pick"]
receipt = answer.choice.lower()  # verbatim copy of one regex match, or "none"

Watch out

Choice caps at 255 options, and candidates without a regex, such as names, must come from a roster, NER, or an LLM.

Questions about this entry

Short answers drawn from the linked project or page.

Reactions & coverage

Posts, threads, and videos about this entry from around the web.

X: A 26-sheet plan set in 2.9 seconds

X: Which exam questions come back

X: 900 images in 40 seconds

From the Jev guides

Original write-ups on what this entry is for.

From the Jev AI model community

Posts from builders shipping with Jev right now.

Follow @typesafeai