Matching double quotes in SPARQL query in Virtuoso

457 views Asked by At

I need to get a SPARQL query that matches double quotes in Virtuoso graph. I use such query:

SELECT distinct ?o
FROM <http://graph>
WHERE
{
    ?s ?p ?o.
}

It returns me a column with such values:

http://some.prefix/Symbol
"abcd"

I need to match only second value ("abcd"). I tried to add such filter to WHERE clause:

FILTER regex(str(?o), "\"")

But it returns no results. I also tried '"' as a second parameter to regex, and some other things. Is it possible at all?

2

There are 2 answers

1
AndyS On BEST ANSWER

"abcd" is a literal of four characters. It does not include the ""; these are the string delimiters and do not form part of the string.

FILTER isLiteral(?o)

should work.

2
Kiran.B On

Since your filter is not working, "abcd" does not have a double quote in it. It's a string literal. Not sure what type it is; so you can use --

select ?type where { "abcd" a ?type }

-- to get its type. You can then use that type as a filter in your query as:

SELECT distinct ?o
FROM <http://graph>
WHERE
{
    ?s ?p ?o .
    ?o a <whatever type you received in the previous query> .
}