On 20/10/15 22:18, Mark Feblowitz wrote:
At my wit’s end here. The asterisk character shows up in strings in dbpedia - a 
lot - and I need to be able to replace it, as it apparently throws of “dot” in 
graph arc labels.

But I can’t seem to find a way to have a SPARQL replace work that doesn’t either 
reject a “metacharacter” like “*” or to do something odd like "\\\*”

And while we’re at it, the same for “\n” in the text.

Recommendations?


\ is a an escape character in SPARQL so to parser you need \\

REPLACE('hello*world', '\\*', ' ')

so that is two \ which SPARQL-escapes into one in the string

but context matters so if this is in java or, a shell-" string (not a shell-' string) or other places where \ is a string escape ...

REPLACE('hello*world', '\\\\*', ' ')

which is 4 backslashes

A/ java-escape \\\\ to \\ in the SPARQL string.

B/ \\ to \ in SPARQL

to leave \*

        Andy

Reply via email to