鉴于此RDF:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rdf:RDF [<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
<!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'>]>
<rdf:RDF xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="Fadi" xml:startTime="00:01:38" xml:endTime="00:01:39">
<ns0:eat xmlns:ns0="http://example.org/">Apple</ns0:eat>
</rdf:Description>
</rdf:RDF>
当我执行此SPARQL查询时
SELECT *
WHERE {
?s ?p ?o .
FILTER (regex(?o, 'Apple','i'))
}
我得到主题和谓词:
s: http://example.org/Fadi , p: http://example.org/eat .
但是当我执行
SELECT *
WHERE {
?s ?p ?o .
FILTER (regex(?s, 'Fadi','i'))
}
要么
SELECT *
WHERE {
?s ?p ?o .
FILTER (regex(?s, 'http://example.org/Fadi','i'))
}
我什么都没有。如何查询主语或谓语?
如何查询
startTime
和endTime
?
最佳答案
?s是一个URI,而正则表达式适用于字符串。使用 str 函数来获取字符串:
FILTER (regex(str(?s), 'Fadi','i'))
关于rdf - 通过正则表达式查询主题或谓词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16250832/