N
N
n0namer2017-04-23 19:34:05
Sphinx
n0namer, 2017-04-23 19:34:05

.NET + Sphinx. How not to escape # and @?

I am using MySqlCommand to connect. I form the text of the request to the Sphinx according to the following template:

"select Id, WEIGHT() as weight from ind WHERE MATCH ('"+ searchString + "')"

The user can enter the characters # and @ and the exception will fly out. To avoid this, I escape these characters:
searchString.Replace("@","\\\\@").Replace("#", "а")

Is there a more generic solution?
What other characters need to be escaped?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2017-04-23
@dimonchik2013

the correct solution is to skip only allowed characters at the
same time with the regexp and you can translate to lower case

P
Puma Thailand, 2017-04-24
@opium

all special characters must be escaped, for this there are ready-made functions in all languages

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question