I wrote I SPARQL
query with JENA
with the REGEX
: /^name$/i
(Actually name
is a String variable that could be any value, with spaces or not, it's received as a parameter of the method).
Here's the String query:
String authorquery = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
"PREFIX dc: <http://purl.org/dc/elements/1.1/> " +
"PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT " +
"?URIAutor WHERE { " +
"?URIAutor foaf:name ?Autor." +
"FILTER (regex(?Autor, \"" + "/^" + name + "$/" + "\", 'i' ) ).}";
That isn't giving me an exception, but isn't returning me results when I write a name that I'm sure is on the Database. That's what I want with this query: I have the name "Agatha Christie" on the database. If name=Agatha
I would like the query to return nothing. I'd like it only to return me the URI from the author named "Agatha Christie" if name="Agatha Christie"(can be case insentive). The same holds for the names "Bill Clinton" and "Bill Gates", if name=Bill
I wouldn't like to find both URIs, but the query should return no results. The result should come for "Bill Clinton" only if name="Bill Clinton"
.
I don't know if the problem is with the REGEX or with turning the REGEX into a String with a variable in the middle.
Could you help me?
Don't put /.../
around the regex string. ^name$
will do.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.