开发者

How to replace ASCII code (alt+207) in JavaScript?

开发者 https://www.devze.com 2023-03-16 05:57 出处:网络
I have a string which contains square boxes(I found it\'s开发者_如何学Python ascii code as alt+207)...

I have a string which contains square boxes(I found it's开发者_如何学Python ascii code as alt+207)...

How can I replace this with ' '(a single space).


I am assuming you mean the character: ¤

If so, you could try,

str = str.replace('\u00A4', ' ');

Or if you want to do it to any character that is not ASCII, you could try something like:

str = str.replace(/[^\u000A\u0020-\u007E]/g, ' ');


Is it one of these characters? ▪ = ▪ or ■ = ■

If so, you can do this

var str ="Something ▪ and ■";
str = str.replace(/▪|■/g, " ");
document.write(str);

http://jsfiddle.net/jasongennaro/8mCuV/

0

精彩评论

暂无评论...
验证码 换一张
取 消