To check the text ABCxyz against the regular expression [A-Z]{3}|\d{6}, we use the following SPARQL query:
SELECT (REGEX("ABCxyz", "^[A-Z]{3}|\\d{6}$") AS ?matches) {}
This will incorrectly return true (resulting in a “compliance” report), since that full REGEX means “starts with [A-Z]{3}, or ends with \d{6}”. What we actually need is this:
SELECT (REGEX("ABCxyz", "^(?:[A-Z]{3}|\\d{6})$") AS ?matches) {}
to make sure that the ^ and $ anchors really apply to the whole regex. (Make sure to use a non-capturing group – some format constraints use capturing groups and backreferences, so we mustn’t change the number of capturing groups.)