SPARQL regex for literal returns nothing even with "match any character"

I'm playing with the music dataset and trying to get REGEX to work in SPARQL queries.

I can do a simple query like:

prefix : <http://stardog.com/tutorial/>
SELECT ?soloartist
WHERE {
   <http://stardog.com/tutorial/ABBA> :member ?soloartist .
}

And predictably get results like this: Screenshot by Lightshot

But any kind of regex search, including "give me any character whatsoever" gives me 0 triples in return.

prefix : <http://stardog.com/tutorial/>

SELECT ?soloartist ?band
WHERE {
   ?band :member ?soloartist 
    FILTER ( REGEX(?band, ".*" ) )
}

This is also true when the regex is a perfect match:

FILTER(REGEX(?band, "<http://stardog.com/tutorial/ABBA>", "i"))

or just has one letter that is expected to be in the returned triple

FILTER(REGEX(?band, "A", "i"))

I've double checked my quotation marks. Is there something Stardog specific I'm not understanding?

Hi Susanne,

REGEXs don't work on URIs, only strings. That's why your second code block is returning no results. If you change it to this, it'll work:

prefix : <http://stardog.com/tutorial/>

SELECT ?soloartist ?band
WHERE {
   ?band :member ?soloartist 
    FILTER ( REGEX(str(?band), ".*" ) )
}

You might think this means your third code block should become this:

FILTER(REGEX(str(?band), "<http://stardog.com/tutorial/ABBA>", "i"))

(I say this because this is what I tested initially.) However, when ?band gets converted to a string, the angle brackets are not included in the result. In other words, str(<http://stardog.com/tutorial/ABBA>) gives "http://stardog.com/tutorial/ABBA". Therefore, your third code block should be:

FILTER(REGEX(?band, "http://stardog.com/tutorial/ABBA", "i"))

Best,
Steve

Thank you Steve, that makes a lot of sense!