Nishtha Nishtha - 1 year ago 73
Ruby Question

Remove unique multiple words from string

I am getting multiple strings from ajax response so there I am getting a strange string which is repeating many times .I try removing it but it didn't work Can Anyone help me out with this problem
Here is the string which I am getting in the output

user = "[\u0026quot;aniket\u0026quot;, \u0026quot;shivam\u0026quot;, \u0026quot;alambagh churah\u0026quot;, \u0026quot;Jyoti tiwari chatur\u0026quot;, \u0026quot;A-12121\u0026quot;, \u0026quot;\u0026quot;, \u0026quot;ANC-22\u0026quot;, \u0026quot;Ahdada-2\u0026quot;, nil, \u0026quot;mobile appli\u0026quot;, \u0026quot;hari tiwari\u0026quot;, \u0026quot;121221\u0026quot;]"

I need to remove
from my string ..
When I do
puts "#{user.classs}"
It says

I tried using
but it didn't work for me or maybe I am not using it properly

user.gsub!('\u0026quot;', '')

I am sending response from my ajax call
function download_csv(user_Data){
//alert(user_Data) //in this basically i am getting the data and from //here I am sending to my controller

url: "users/download",
type: "POST",
data: {user_Data: duser_Datata},
dataType: "text",

complete: function(){
success: function(data,xhr){

error: function(){
alert('ajax error')


Answer Source

Try to use user.gsub!("\u0026quot;", '')

'escape sequence' does not work in single quote string.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download