Combine patterns with typed checks

fn:matches checks the shape of text. Numeric casts and comparisons check its values. These examples use a separate XPath library to preview authored rules as you edit; they do not submit or persist data.

The form accepts a 3–16 character ASCII user name, an integer age from 18 to 120, and short letter-only tags. Try a leading digit in the name, age 17, or an empty tag between commas. Regex tokenize separates tags, every checks them, and replace formats the accepted list.

The IPv4 preview checks four decimal octets and an optional CIDR prefix, then compares the prefix length with a local allow-list using some. No slash means /32. Leading zeros are rejected. The rule checks prefix lengths; it does not test subnet membership or install network rules. IPv6 is outside this example.

The regex subset supports groups, alternatives, classes, bounded and reluctant repetition, Unicode categories, and the s, x and q flags. Backreferences, class subtraction, XML name/block escapes, and i/m modes are explicitly unsupported. XPath whitespace and replacement rules apply. The tag rule explicitly accepts both ASCII letter cases and preserves their spelling. Pattern, input and work limits apply; see the XPath reference. Regex alone is not complete address or form validation.

See also

XPath text functions and live text · XPath maps and arrays · XPath stable sorting