OCR Extract Pattern
OCR Extract Pattern
Section titled “OCR Extract Pattern”Type: ocr-extract-pattern · Package: OCR Activities v1.0.0 · Output: Dictionary
It combines OCR + regular expressions in a single step: it recognizes the text of an image and, on that text, applies a set of patterns (regex) to extract specific fields. Returns a { campo: valor } dictionary. It is the most direct way to extract structured data from a scanned document (invoice number, date, total).
How it works
Section titled “How it works”Runs OCR on the image and, on the resulting text, evaluates each pattern in the patterns dictionary. For each pattern that matches, add nombreCampo → valor to the result. Use a capture group in the regex to extract only the part you are interested in.
Required parameters
Section titled “Required parameters”| Parameter | Editor | Description |
|---|---|---|
path | expression | Image file path. |
patterns | objeto | nombreCampo → patrón regex Dictionary. Use a capture group to extract the value. |
Optional parameters
Section titled “Optional parameters”| Parameter | Editor | Description |
|---|---|---|
language | expression | Language code: eng (def.) · spa · eng+spa. |
preprocess | expression | Limpieza previa: none (def.) · auto · deskew · binarize. |
Output
Section titled “Output”Returns a Dictionary with a pair for each pattern that was matched.
Example
Section titled “Example”Extract number, date and total from a scanned invoice:
OCR Extract Pattern path = = rutaFactura language = "spa" preprocess = "auto" patterns = { "numero": "FAC-(\d+)", "fecha": "Fecha:\s*(\d{4}-\d{2}-\d{2})", "total": "Total:\s*\$?([\d.,]+)" } → output: datos
Log message = = "Factura " + datos["numero"] + " — Total " + datos["total"]Related activities
Section titled “Related activities”- OCR Recognize File — get the text and extract it yourself with
regexFind. - OCR Extract Form Fields — extract by position instead of pattern.