ruby - When trying to escape apostrophe with 'gsub', I get backreference -


this question has answer here:

i have code:

"1'2".gsub("'","\\'") 

instead of "1\'2", get: "122". why?

it because "\\'" means context following match, "2".


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -