The following query:
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT DISTINCT ?subject
WHERE
{
?x qb:component ?subject .
}
deployed via this publicly available endpoint: http://statistics.gov.scot/sparql-beta produces a list of available subjects:
http://statistics.gov.scot/def/component-specification/pupil-attainment/refArea
http://statistics.gov.scot/def/component-specification/pupil-attainment/refPeriod
http://statistics.gov.scot/def/component-specification/pupil-attainment/measureType
http://statistics.gov.scot/def/component-specification/pupil-attainment/count
http://statistics.gov.scot/def/component-specification/pupil-attainment/pupils
http://statistics.gov.scot/def/component-specification/pupil-attainment/ratio
I would like to filter the available results using regex, similary to the linked example:
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
SELECT ?g
WHERE
{ ?y vcard:Given ?g .
FILTER regex(?g, "r", "i") }
when attempted:
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT DISTINCT ?subject
WHERE
{
?a qb:component ?subject .
FILTER regex(?subject, "p", "i")
}
the query returns table with no rows. Is there a way I could filter the obtained values?
I think that you should call the str
function on ?subject
, it is not a string but rather a URI, so first you have to convert it to a string.
This should work:
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT DISTINCT ?subject
WHERE
{
?a qb:component ?subject .
FILTER regex(str(?subject), "p", "i")
}