XQuery MarkLogic 中的模式或格式匹配

Pattern or Format Match in XQuery MarkLogic

我正在寻找给定的字符串,它必须是 *(*) 格式,* 不应该有 space,( 之前没有两个单词。

我正在搜索 MarkLogic DB 以查看给定列值是否采用 [^\s]+\((?!\s)[^()]+(?<!\s)\) 格式,如果不是,则将其替换为这种格式。

我仍然卡在获取数据,无法编写查询来更新

我正在搜索数据库

    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 函数不支持 (?!(?<! 等组修饰符。简化您的模式,并在必要时用另一场比赛在比赛后捕获误报。

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

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

HTH!