大家好,你们有谁知道 jena 中有一个函数可以拆分(除了拆分函数)一个 URI 字符串

hello all does anyone of you know a function in jena to split( other than split function) a URI string

例如,对于像这样的字符串: “https://www.example.com/myname:abcd

我只想要“:”之前的部分 即我想要如下输出: “https://www.example.com/myname

在 SPARQL 中:

REPLACE("https://www.example.com/myname:abcd", ":[^:]*$", "")

在代码中,使用普通的 java 字符串操作。

你想要的是提取资源的命名空间。

resource.getNamespace() 会成功的 ;)