[英]How to delete elements with regex in BaseX
I have a BaseX database that has the following format 我有一个具有以下格式的BaseX数据库
<root>
<node1>
<value1>abctetabc</value1>
<value2>...</value2>
</node1>
<node1>
<value1>abctatabc</value1>
<value2>...</value2>
</node1>
</root>
I would like to ask about how can I delete nodes that their value includes tet. 我想问一下如何删除其值包含tet的节点。 Have I to use regex?
我有使用正则表达式吗?
the normal delete is executed like this 正常的删除是这样执行的
XQUERY delete root/node1[value1='abctatabc']
How can I do a search for a substring? 如何搜索子字符串?
If you want to delete nodes in a database, you can use delete node root/node1[value1='abctatabc']
(see XQuery Update in the BaseX documentation). 如果要删除数据库中的节点,则可以使用
delete node root/node1[value1='abctatabc']
(请参阅BaseX文档中的XQuery Update )。 If you want to delete it without changing the original document, you can use the update
keyword: 如果要删除它而不更改原始文档,则可以使用
update
关键字:
document {
<root>
<node1>
<value1>abctetabc</value1>
<value2>...</value2>
</node1>
<node1>
<value1>abctatabc</value1>
<value2>...</value2>
</node1>
</root>
} update {
delete node root/node1[value1 = 'abctatabc']
}
Of course you can also look for substrings (via fn:contains
) or use regular expressions (via fn:matches
): 当然,您也可以查找子字符串(通过
fn:contains
)或使用正则表达式(通过fn:matches
):
delete node root/node1[matches(value1, 'abc')]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.