Reputation: 433
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;[email protected]\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 \u0026quot;
from my string ..
When I do puts "#{user.classs}"
It says String
I tried using gsub
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
$.ajax({
url: "users/download",
type: "POST",
data: {user_Data: duser_Datata},
dataType: "text",
complete: function(){
},
success: function(data,xhr){
},
error: function(){
alert('ajax error')
}
})
}
Upvotes: 0
Views: 296
Reputation: 2869
I thing you need to use this rgx with gsub
will help, if you need to modify the original string use gsub!
.
s = "["aniket", "shivam", "alambagh churah", "Jyoti tiwari chatur", "A-12121", "[email protected]", "ANC-22", "Ahdada-2", nil, "mobile appli", "hari tiwari", "121221"]"
s.gsub(/\\u0026quot;/, "")
# => "["aniket", "shivam", "alambagh churah", "Jyoti tiwari chatur", "A-12121", "[email protected]", "ANC-22", "Ahdada-2", nil, "mobile appli", "hari tiwari", "121221"]"
Upvotes: 0
Reputation: 12818
Try to use user.gsub!("\u0026quot;", '')
'escape sequence' does not work in single quote string.
Upvotes: 1