My apologies. I replied too quickly. I just wrote this test with Jena's command line tools. To match the string "+35", I had to use the "\\+35" in the query:
select ?label where { values ?label { "+35" "-35" } filter(regex(str(?label),"\\+35")) } --------- | label | ========= | "+35" | --------- That's _two_ slashes in the query string, which means that in Java you'd end up writing String query = ... + "filter(regex(...,\"\\\\+35\")" + ...; Sorry for the hasty and inaccurate reply. On Mon, Jan 20, 2014 at 9:27 PM, Joshua TAYLOR <joshuaaa...@gmail.com> wrote: > On Mon, Jan 20, 2014 at 8:48 PM, Martynas Jusevičius > <marty...@graphity.org> wrote: >> OK maybe "+35" was a bad example. But isn't "+" a special char in >> SPARQL regex? And there are more like "*", "?" etc. >> http://www.w3.org/TR/xpath-functions/#regex-syntax > > > Oh, good point. But if it needs to be escape with a slash, then wouldn't > > filter regex(str(?label), "\+35") > > be fine? Note that if you're constructing this programmatically, you > might end up writing code like > > String queryString = ... + "filter regex(str(?label), \"\\+35\")" + ...; > > -- > Joshua Taylor, http://www.cs.rpi.edu/~tayloj/ -- Joshua Taylor, http://www.cs.rpi.edu/~tayloj/