Page MenuHomePhabricator

sparql replace "q" modifier not accepted
Closed, ResolvedPublic


The below sample adapted from the function spec used in sparql doesn't seem work:

SELECT * { BIND( replace("a\b\c", "\", "\\", "q") as ?test) }

Result should be:


Maybe it's deactivated on purpose.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Apparently, all backslashes need to be escaped, which is the actual problem of the query. While \b is backspace character, \c is nothing.

Another error you've got in the query is the backslash in the second literal...

SELECT * { BIND( replace("a\b\c", "\", "\\", "q") as ?test) }

... which escapes the following double quote mark, causes the second argument to be "\", " (notice the syntax highlighting) and makes the number of quote marks unballanced.

After all, what does the "q" stand for?

q="don't escape the backslash" :)

I think its defined at and that should be included in sparql

Smalyshev added a subscriber: Smalyshev.

Yes, it looks like Blazegraph is missing support for "q" option. Fortunately, Java has Pattern.LITERAL mode that does exactly this, which makes fixing this easy.

Smalyshev triaged this task as Medium priority.Jun 21 2018, 5:12 PM

About this query:

SELECT * { BIND( replace("a\b\c", "\", "\\", "q") as ?test) }

I don't think this would work regardless of 'q' option. This option makes regex special characters lose their special meanings (inside regex context) but it does not change SPARQL grammar. And in SPARQL grammar things like "\" are invalid, and the literal parser will still parse literals according to the same set of rules.

Better test case would be:

SELECT * { BIND( replace("abc", ".", "Z", "q") as ?test) }

Here . should lose it's "catch all" meaning with 'q' option.

Vvjjkkii renamed this task from sparql replace "q" modifier not accepted to draaaaaaaa.Jul 1 2018, 1:03 AM
Vvjjkkii reopened this task as Open.
Vvjjkkii removed Smalyshev as the assignee of this task.
Vvjjkkii raised the priority of this task from Medium to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
CommunityTechBot renamed this task from draaaaaaaa to sparql replace "q" modifier not accepted.Jul 2 2018, 4:42 AM
CommunityTechBot closed this task as Resolved.
CommunityTechBot assigned this task to Smalyshev.
CommunityTechBot lowered the priority of this task from High to Medium.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added a subscriber: Aklapper.