The current regular expression functions allow you to pass in flags to alter the regular expression processing. One of these flags implemented in Saxon is the exclamation mark to indicate that the regular expression be treated as a Java regular expression rather than one conforming to the current specification.
It would be good to have a standard way of extending or switching the regular expression syntax/processing engine that would not be implementation specific.
I agree (despite being slightly embarrassed to have this "easter egg" exposed in public).
I would suggest
flags ::= standard-flags ( ';' imp-def-flags )?
standard-flags ::= [imsx]
imp-def-flags ::= .*
where the effect of imp-def-flags on the syntax and semantics of the regular expression is implementation-defined.