Regular Expressions 101

ISO 32000-1 PDF Header, XRef Table & EOF Stream Validator

Open Workspace
  • PCRE2 (PHP)
  • Match
2

Regular Expression

/
^%PDF-(1\.[0-7]|2\.0)\b[\s\S]*?(?:\bxref\b|\bstartxref\b)[\s\S]*?%%EOF\s*$
/
gm

Description

Validates structural markers of an ISO 32000-1 / ISO 32000-2 PDF byte stream, including the %PDF-1.x / %PDF-2.0 version header, cross-reference (xref or startxref) pointer block, and terminal %%EOF trailer marker.

Use Case & Reference Implementation

Designed for client-side pre-flight validation before WebAssembly cross-reference reconstruction in the Utilvo Client-Side PDF & Developer Toolkit .

  • Group 1 (1\.[0-7]|2\.0): Captures the PDF specification revision.
  • Cross-Reference Anchor: Ensures either a classic xref table or compressed object stream startxref offset exists prior to %%EOF.
Submitted by Utilvo Systems Engineering