On 09/16/19 17:10, Tom Lane wrote: > I was initially troubled > by the fact that XML Schema regexps are implicitly anchored, ie must > match the whole string; that's a huge difference from POSIX. However, > 19075-6 says that jsonpath like_regex works the same as the LIKE_REGEX > predicate in SQL; and SQL:2011 "9.18 XQuery regular expression matching" > defines LIKE_REGEX to work exactly like XQuery's fn:matches function, > except for some weirdness around newline matching; and that spec > clearly says that fn:matches treats its pattern argument as NOT anchored.
Yeah, it's a layer cake. XML Schema regexps[1] are implicitly anchored and don't have any metacharacters devoted to anchoring. XQuery regexps layer onto[2] XML Schema regexps, adding ^ and $ anchors, rescinding the implicit anchored-ness, adding reluctant quantifiers, capturing groups, and back-references, and defining flags. Then ISO SQL adds a third layer changing the newline semantics, affecting ^, $, ., \s, and \S. Regards, -Chap [1] https://www.w3.org/TR/xmlschema-2/#regexs [2] https://www.w3.org/TR/xpath-functions-31/#regex-syntax