How to filter distinct regex matches with sparql?

by arnoldo.moen , in category: MySQL , a month ago

How to filter distinct regex matches with sparql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by raven_corwin , a month ago

@arnoldo.moen 

You can filter distinct regex matches in SPARQL by using the DISTINCT keyword in combination with the regex function. Here is an example query that demonstrates how to filter distinct regex matches in a SPARQL query:


PREFIX foaf: http://xmlns.com/foaf/0.1/SELECT DISTINCT ?name WHERE { ?person foaf:name ?name . FILTER regex(?name, "John", "i") }


In this query, we are querying for the distinct values of the ?name variable where the value matches the regex pattern "John" case-insensitively. The DISTINCT keyword ensures that only distinct values are returned in the result set.