本文介绍了XQuery MarkLogic中的模式或格式匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找给定的字符串,它必须为*(*)格式,*不应有空格,在(之前不能有两个单词.

I am looking for given string, it has to be in *(*) format, * should not have space, no two words before (.

我正在搜索MarkLogic DB,以查看给定的列值是否为[^\s]+\((?!\s)[^()]+(?<!\s)\)格式,如果未使用此格式替换.

I am searching MarkLogic DB to see if given column value is in [^\s]+\((?!\s)[^()]+(?<!\s)\) format, if not replace it with this format.

我仍然停留在获取数据上,无法编写要更新的查询

I am still stuck at fetching data, and could not write the query to update

我正在将数据库搜索为

    let $query-opts := cts:search(doc(),
      cts:and-query((
        cts:directory-query(("/xyz/documentData/"),"1"),  
            cts:element-query( 
                xs:QName("cd:clause"),  (: <clause> element inside extended for checking query id :)
                cts:and-query((
                    cts:element-attribute-value-query( xs:QName("cd:clause"), xs:QName("tag"), "Title" ),  (: only if the <clause> is of type "Title" :)
                    cts:element-attribute-value-query( xs:QName("cd:xmetadata"), xs:QName("tag"), "Author")

                ))
             )
        ))
for $d in $query-opts
return (
     for $x in $d//cd:document/cd:clause/cd:xmetadata[fn:matches(@tag,"Author")]/cd:metadata_string
     where fn:matches($x/string(), "[^\s]+\((?!\s)[^()]+(?<!\s)\)")
       return 
       (   <documents> {
      <documentId> {$d//cd:cdf/cd:documentId/string()}</documentId>
     }</documents>
       )
     )

正在抛出错误无效模式

推荐答案

fn:matches 函数不支持(?!(?<!之类的组修饰符.简化您的模式,并在必要时与另一场比赛进行比赛之后捕获误报.

The fn:matches function does not support group modifiers like (?! and (?<!. Simplify your pattern, and capture false positives after the match with another match if necessary.

对您要尝试做的事情进行有根据的猜测,我认为您正在寻找类似的东西:

Doing an educated guess at what you are trying to do, I think you are looking for something like:

where fn:matches($x, '^.+\([^)]+\).*$') (: it uses parentheses :)
  and fn:not(fn:matches($x, '^[^\s]+\([^\s)]+\)$')) (: but does not comply to strict rules :)

HTH!

这篇关于XQuery MarkLogic中的模式或格式匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 03:53