Remove non-ascii character in string

Dev picture Dev · Dec 31, 2013 · Viewed 107k times · Source
var str="INFO] :谷���新道, ひば���ヶ丘2丁���, ひばりヶ���, 東久留米市 (Higashikurume)";

and i need to remove all non-ascii character from string,

means str only contain "INFO] (Higashikurume)";

Answer

Zaffy picture Zaffy · Dec 31, 2013

ASCII is in range of 0 to 127, so:

str.replace(/[^\x00-\x7F]/g, "");