Warm tip: This article is reproduced from serverfault.com, please click

SPARQL

发布于 2020-12-09 23:23:26

I want to find a query that select the ClassName that doesn't begin with an uppercace. The architecture is:

SELECT DISTINCT ?prop WHERE { { ?prop rdf:type owl:Class . } UNION { ?prop rdf:type owl:DatatypeProperty . } MINUS { #To DO }. }

Questioner
Hugo Tortosa
Viewed
0
Lucas Mercier 2020-12-11 02:17:21

You can't perform regex directly on your ?prop because it probably contains the prefix and you don't want it.

First you have to remove the prefix (let's say your prefix is ":")

bind(strafter(str(?class),str(:)) as ?propertyName)

It will create a var called propertyName that contains only the name (without prefix)

Now that you have this you can perform regex on it. If you only want to keep properties starting with a capital case you can do:

FILTER regex(str(?propertyName),"^[A-Z]")

Note: if you want to verify every rules of camelCase you can check this regex