javascript cant remove invisible ascii character

  ascii, javascript, replace

I have the following string:

Backpacks‎

Which if you copy and paste into the website http://asciivalue.com/ to examine each ascii char inside that string, you can see that after the text ‘Backpacks’ there is the ascii value: , this value messes up when I try to write the string to a csv file, as it will get outputted as Backpacks‎

I have tried using .replace functions like subcategoryStr.replace(/[^x00-x7F]/g, ""); and replace(/[^x20-x7E]/g, ''); to remove any of these invisible nonstandard ascii but no luck, how can I remove this invisible character from a string in javascript?

Source: Ask Javascript Questions

LEAVE A COMMENT