Asked • 05/30/19

How to check whether a string contains a substring in Ruby?

I have a string variable with content as follows: varMessage = "hi/thsid/sdfhsjdf/dfjsd/sdjfsdn\\n" "/my/name/is/\\n" "call::myFunction(int const&)\\n" "void::secondFunction(char const&)\\n" . . . "this/is/last/line/"in above string i have to find a sub string i.e. "hi/thsid/sdfhsjdf/dfjsd/sdjfsdn\\n" "/my/name/is/\\n" "call::myFunction(int const&)\\n"How can I find it? I just need to determine whether the substring is present or not.

1 Expert Answer


Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.