Reputation: 628
I am trying to perform a relative simple regex query, however it uses a variable inside the regexp. Is sparql not capable of using these kind of concatenation or am I using a wrong method? What I am trying to query is the following:
SELECT *
WHERE {
?part local:part_start ?start .
?chunk local:long_region ?long_region
BIND(REPLACE(?long_region, ".{"+?start+"}(.{10}).*", "$1") AS ?regionX)
}
I will end up with a small part from a long region of characters according to a start location and 10 characters further.
Upvotes: 1
Views: 779
Reputation: 28675
No +
cannot be used for string concatenation in most SPARQL implementations, in principal an implementation can support this as an extended operator mapping but I'm not aware of any that do.
Instead you can use the standard CONCAT()
function to achieve your aim provided you are using a SPARQL 1.1 compliant engine:
SELECT *
WHERE {
?part local:part_start ?start .
?chunk local:long_region ?long_region
BIND(REPLACE(?long_region, CONCAT(".{", ?start, "}(.{10}).*"), "$1") AS ?regionX)
}
Upvotes: 2