On Tue, Jan 21, 2014 at 7:40 AM, Michael Brunnbauer <bru...@netestate.de> wrote: > > I was just refering to the documentation of ParameterizedSparqlString, which > says that "injection is done by textual substitution": > > > http://jena.apache.org/documentation/javadoc/arq/com/hp/hpl/jena/query/ParameterizedSparqlString.html
If you're using a ParameterizedSparqlString, the escaping still seems to be handled correctly. The string that you'd want to inject is `\+35`, which is written as `\\+35` in Java. Here's and example and its output: import com.hp.hpl.jena.query.ParameterizedSparqlString; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFormatter; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; public class ParameterizedSparqlRegexSubstitution { public static void main(String[] args) { final Model empty = ModelFactory.createDefaultModel(); final ParameterizedSparqlString query = new ParameterizedSparqlString( "select * where {\n" + " values ?label { \"+35\" \"-35\" }\n" + " filter( regex( str(?label), ?pattern ))\n" + "}\n" ); query.setLiteral( "?pattern", "\\+35" ); System.out.println( query.toString() ); final QueryExecution exec = QueryExecutionFactory.create( query.asQuery(), empty ); final ResultSet results = exec.execSelect(); ResultSetFormatter.out( results ); } } select * where { values ?label { "+35" "-35" } filter( regex( str(?label), "\\+35" )) } --------- | label | ========= | "+35" | --------- -- Joshua Taylor, http://www.cs.rpi.edu/~tayloj/