Advertisement
Guest User

Escaping

a guest
Feb 8th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.22 KB | None | 0 0
  1. def escape_quotes(str)
  2.   if str
  3.     result = str.gsub(/(\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u) {|match| ESCAPE_MAP[match] }
  4.  else
  5.    ''
  6.  end
  7. end
  8.  
  9.  
  10. escapedStr = escape_quotes(string)
  11. puts escapedStr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement