How to find the character in string

I have a string where i need to find out if particular character is
present in that string or not…

I need to verify that string does not contain “\”
for that I am doing something like below

String path=“C:\Gaurang\ruby\demo.xls”
if (!path.index("\").nil?) then
#Do process here
end
but it is not working.

its because “\” is not in your string see my post in your other thread

and
String path=“C:\Gaurang\ruby\demo.xls”
is not good ruby code because it is interpreted as
String(path=“C:\Gaurang\ruby\demo.xls”)
with is meanless,use
path = ‘C:\Gaurang\ruby\demo.xls’
or
path = “C:\Gaurang\ruby\demo.xls”

yes you are right my string doesn’t contain “\”, however I am using
that in sub function with “\” coz “” is a escape character.

Hans M. wrote in post #1012177:

its because “\” is not in your string see my post in your other thread

and
String path=“C:\Gaurang\ruby\demo.xls”
is not good ruby code because it is interpreted as
String(path=“C:\Gaurang\ruby\demo.xls”)
with is meanless,use
path = ‘C:\Gaurang\ruby\demo.xls’
or
path = “C:\Gaurang\ruby\demo.xls”