小编Gus*_*usa的帖子

SPARQL正则表达式过滤器

我试图通过使用正则表达式过滤器匹配SPARQL中的一个单词,但没有成功...:/我将查询发送到位于"http://dbtune.org/musicbrainz/sparql"的端点.那么,以下查询有效:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX mo: <http://purl.org/ontology/mo/>
SELECT ?artist ?name
WHERE {
    ?artist a mo:MusicArtist
    . ?artist foaf:name "Switchfoot"
    . ?artist foaf:name ?name
    . FILTER(regex(str(?name), "switchfoot", "i"))
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我删除第7行(.?artist foaf:name"Switchfoot"),则以下查询不匹配:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX mo: <http://purl.org/ontology/mo/>
SELECT ?artist ?name
WHERE {
    ?artist a mo:MusicArtist
    . ?artist foaf:name ?name
    . FILTER(regex(str(?name), "switchfoot", "i"))
}
Run Code Online (Sandbox Code Playgroud)

我不知道我是做错了什么,还是端点错误......

有人能帮助我吗?

regex rdf sparql pattern-matching

5
推荐指数
1
解决办法
8357
查看次数

标签 统计

pattern-matching ×1

rdf ×1

regex ×1

sparql ×1