I am new to XQuery so could you please help me to understand what is § and §.*$ in below MarkLogic XQuery:
if (matches($cite, '§'))
replace($cite,'§.*$','')
here $cite := "HI CONST Preamble"
I am new to XQuery so could you please help me to understand what is § and §.*$ in below MarkLogic XQuery:
if (matches($cite, '§'))
replace($cite,'§.*$','')
here $cite := "HI CONST Preamble"
Copyright © 2021 Jogjafile Inc.
In regex, the
$in a regex expression is an anchor point to the end of the input string value.§is a numeric entity reference of the§character, and.is a wildcard and the*is a quantifier meaning zero to many.The
matches()expression is testing whether the$citecontains the§character. If it does, then it attempts toreplace()the§and all of the characters following it until the end of the input with nothing.For example:
returns: "no match" because it doesn't contain the
§at all.However, this:
Returns: "HI CONST Preamble" because it does contain
§, so§foo bar baz.is replaced with "".