archivist: firstMatch examples use pages expressions

This commit is contained in:
2026-11-01 11:51:49 +01:00
parent bfc02c626f
commit b6f23a30f9
+7 -6
View File
@@ -37,11 +37,12 @@
// matched; nesting is recursive // matched; nesting is recursive
// //
// Built-in helpers: // Built-in helpers:
// firstMatch(regex, pages?) returns the first match of the regex // firstMatch(regex, texts?) returns the first match of the regex
// in the document text (first capture group when present); pages?: a // in the document text (first capture group when present); texts? is an
// number searches that page (1-based), [a, b] searches pages a to b // expression evaluated to the text(s) to search: pages[0] searches
// inclusive, a longer list searches exactly those pages, omitted = // the first page, pages[0:3] searches pages 1 to 3 (expr slice
// the whole document. // syntax, end exclusive), any list of strings works; omitted = the
// whole document.
// period(value, unit, shift, layout?) renders a period instead of a // period(value, unit, shift, layout?) renders a period instead of a
// raw date: unit = `month`|`quarter`|`half`|`year`, shift = -1/0/+1 // raw date: unit = `month`|`quarter`|`half`|`year`, shift = -1/0/+1
// for the previous / containing / next period (rent receipt: 0, // for the previous / containing / next period (rent receipt: 0,
@@ -62,7 +63,7 @@
{ {
"when": "true", "when": "true",
"set": [ "set": [
{ "field": "emissionDate", "eval": "date(firstMatch(`[0-9]{2}/[0-9]{2}/[0-9]{4}`, 1), `02/01/2006`)" } { "field": "emissionDate", "eval": "date(firstMatch(`[0-9]{2}/[0-9]{2}/[0-9]{4}`, pages[0]), `02/01/2006`)" }
] ]
}, },