我正在寻找包含其中包含特定文本字符串的匹配 URI 或文本节点列表。
这允许我搜索具有匹配字符串的任何主题,但我还想返回任何匹配的谓词或对象 - 所有这些都在同一个查询中。
select ?s ?p ?o WHERE {
?s ?p ?o .
FILTER (REGEX(STR(?s), "SEARCHTEXT", "i"))
}
知道如何修改吗?
我正在寻找包含其中包含特定文本字符串的匹配 URI 或文本节点列表。
这允许我搜索具有匹配字符串的任何主题,但我还想返回任何匹配的谓词或对象 - 所有这些都在同一个查询中。
select ?s ?p ?o WHERE {
?s ?p ?o .
FILTER (REGEX(STR(?s), "SEARCHTEXT", "i"))
}
知道如何修改吗?
select ?s ?p ?o WHERE {
?s ?p ?o .
FILTER ( REGEX(STR(?s), "SEARCHTEXT", "i") ||
REGEX(STR(?p), "SEARCHTEXT", "i") ||
REGEX(STR(?o), "SEARCHTEXT", "i") )
}
What use case do you intend this for? Since you want to search for it, your regular expression seems to express some valuable information about the tokens it matches on. If this is the case, it would seem sensible to mark up your data with some relation making this knowledge explicit!
A regex search as you intend seems sensible only in a very few cases, e.g. for a DBMS administration front end. If you just want to solve the problem, I would do something like this (in code, not as a query):
result = data.subjectSet().add(data.predicateSet()).add(data.objectSet())
FOREACH (token ε result) {
result.remove(token) unless(token ≙ regex)
}
return result;