My application needs to match the correct word i.e. say C or C++ with SPARQL. I have the following SPARQL query
String prolog = "PREFIX kb: <" + VBOOK.getURI() + ">";
String queryString = prolog
+ "\n"
+ "SELECT * "
+ "WHERE {?x kb:Price ?price. ?x kb:Currency ?currency. ?x kb:Title ?title. ?x kb:Count ?count. "
+ "OPTIONAL {?x kb:Description ?description}."
+ "FILTER regex(?title, \"" +title + "\")}";
This matches me all books even C++,C# and books like -Real Concepts in Embedded Systems (because of the word 'Concepts' having 'C').
if I change the last line to
+ "FILTER regex(?title, \"" +"^"+title + "\")}";
and if title is for example 'C' then my query matches only those books whose titles start with letter 'C'.So books like 'Programming in ANSI C' are not selected.
I have also tried with the following change in the last line
+ "FILTER regex(str(?title), \"" +title + "\")}";
Even this has not helped me much.
How do I modify to get the books pertaining to 'C' even if the books title do not start with C?
Regards, Archana.