我是 XQuery 的新手,所以請你幫我理解一下MarkLogic XQuery的內容§和內容:§.*$
if (matches($cite, '§'))
replace($cite,'§.*$','')
這里$cite := "HI CONST Preamble"
uj5u.com熱心網友回復:
在正則運算式中,$正則運算式中的 是指向輸入字串值末尾的錨點。
§是字符的數字物體參考,是通配符,是量詞,表示從零到多。§.*
該matches()運算式正在測驗 是否$cite包含該§字符。如果是這樣,那么它會嘗試搜索它后面replace()的§所有字符,直到輸入結束,什么都沒有。
例如:
let $cite := "HI CONST Preamble"
return
if (matches($cite, '§'))
then replace($cite,'§.*$','')
else "no match"
回傳:“不匹配”,因為它根本不包含§。
然而,這:
let $cite := "HI CONST Preamble §foo bar baz."
return
if (matches($cite, '§'))
then replace($cite,'§.*$','')
else "no match"
回傳:“HI CONST Preamble”,因為它確實包含§,所以§foo bar baz.被替換為“”。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/475179.html
