Transit safety analysts must count how many plate-like tokens appear in each incident narrative. Which regex function should they use?
Select an answer to reveal the explanation.
Short Explanation
REGEXP_COUNT is the tally clicker for every plate-shaped token in the write-up—great for spotting how often identifiers show up. Replace and JSON builders are doing different jobs.
Full Explanation
Transit safety analysts counting how many plate-like tokens appear in each incident narrative need a match tally per row. REGEXP_COUNT applies the plate pattern to the narrative and returns how many non-overlapping (or engine-defined) matches occur—useful for spotting narratives dense with identifiers before redaction or for quality checks on report completeness.
REGEXP_REPLACE transforms text; using it only to “count without changing text” is the wrong function when a dedicated count exists. JSON_OBJECT builds JSON objects; it does not count license-plate patterns in unstructured prose. A filtered index can speed predicates on stored columns but does not compute narrative match counts without a regex (or equivalent) expression.
Exam caveat: plate patterns differ by jurisdiction; over-permissive patterns inflate counts with random alphanumerics. Operational check: craft narratives with zero, one, and three synthetic plate-like tokens, run REGEXP_COUNT, and confirm the integers match before rolling the expression into a reporting view. Use counts as an analytic signal—high counts may warrant redaction workflows—while still extracting concrete tokens with REGEXP_SUBSTR when investigators need the actual plate candidates. Store the count in a reporting mart if dashboards repeatedly scan large narrative tables, refreshing on a schedule rather than computing regex on every interactive query.