I don't understand what is going on here. How should I feed gsub to get the string "Yaho'o"?
>> "Yaho'o".gsub("Y", "\Y") => "\Yaho'o" >> "Yaho'o".gsub("'", "\'") => "Yahooo"
' means $' which is everything after the match. Escape the again and it works
"Yaho'o".gsub("'", "\\'")
2.1m questions
2.1m answers
60 comments
57.0k users