Escaping special characters :, (, ), [, ], {, }, !, +, ", ~, ^, -, |, <, >, =, *, ?, \

Hello,

I am trying to escape words for searching i.e., “hello”. The key here
is that the two L’s on “hello” are actually vertical bars. Is there
a special function in Ferret or anywhere for that matter that will do
the escaping of the Ferret special characters?

Thanks in advance,

Benjamin

Hello,

I am going to answer my own questions…

You can do something like:

def escape_string(str)
str = Regexp.escape(item[:word]).gsub(/([:~!<>="])/,’\\\1’)
end

At one time there was a function called clean_string in QueryParser
but it appears to be gone.

Benjamin

Woops… corrected code below:

def escape_string(str)
return Regexp.escape(str).gsub(/([:~!<>="])/,’\\\1’)
end