couchbase n1ql-inline regex捕获的组替换?

2eafrhcq  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(319)
UPDATE SOME_BUCKET as doc USE KEYS ["USER_ACCESS::123456::SOME_ROLE", "MORE KEYS HERE...", etc]
loc.id = REGEXP_REPLACE(loc.id, "(.*) - (.*)", "$1-$2") FOR loc IN locations END
RETURNING doc

在这里设置“loc.id”只是为其分配字符串文字替换值“$1-$2”,而不是对捕获的组的反向引用。
couchbase服务器运行golang regex语法,显然可能不支持反向引用?还有什么选择?

soat7uwm

soat7uwm1#

更新所需集合,unset子句https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/update.html#update-检查示例3

UPDATE SOME_BUCKET as doc 
USE KEYS ["USER_ACCESS::123456::SOME_ROLE", "MORE KEYS HERE...", etc]
SET loc.id = REGEXP_REPLACE(loc.id, "(.*) - (.*)", "$1-$2") FOR loc IN locations END
RETURNING doc;

相关问题