我正在尝试使用XQuery从字符串中提取日期。
let $string := "This string has a yymmdd date like 151123 in it."
(: I need the date bit -> 151123 :)
let $regex := "[0-9]{2}[0-1][0-9][0-3][0-9]"
使用replace()
和tokenize()
我可以获取除匹配字符串以外的所有内容。该functx:get-matches()
函数看起来可以解决问题,但我不能使用它。
您应该匹配整个字符串,将日期分组并用分组替换:
fn:replace($string, "^.*([0-9]{2}[0-1][0-9][0-3][0-9]).*$", "$1")
我无法测试代码,但希望您能掌握常规过程。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句