'Passing an arguement in a label in a query written in SPARQL

I am trying to query Wikidata for the uris of entities, given their label. I am passing the label as a string argument in the query like this:

?uri skos:altLabel|skos:prefLabel|rdfs:label \" """+argument+"""\"@en .

However, due to the space that I have to leave between " and """+argument+""" my query does not find any results because the label doesn't match any existing one. If I don't use a space, then all four " stick together and the syntax of the query gets ruined.

Does anybody have any solutions that will allow me to find results for my query?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source