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:
?test a\\b\\c
Maybe it's deactivated on purpose.
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:
?test a\\b\\c
Maybe it's deactivated on purpose.
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 http://www.w3.org/TR/xpath-functions/#regex-syntax and that should be included in sparql
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.
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.