最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

JavaScript - Remove Unit Separator (Unicode: 0x1f) Character From String - Stack Overflow

programmeradmin3浏览0评论

How do you remove Unit Separator (Unicode: 0x1f) from a string using javascript?

I have string that is creating xml however the Unit Separator character is making the XML invalid. Is there a way in JavaScript to strip out such a character?

I have tried this however it does not work:

input.replace('/\c_/g', '');

How do you remove Unit Separator (Unicode: 0x1f) from a string using javascript?

I have string that is creating xml however the Unit Separator character is making the XML invalid. Is there a way in JavaScript to strip out such a character?

I have tried this however it does not work:

input.replace('/\c_/g', '');

Share Improve this question asked Feb 20, 2013 at 17:08 mmkdmmkd 9001 gold badge14 silver badges28 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 5

This should work:

input = input.replace(RegExp(String.fromCharCode(31),"g"),"")

You can add a character whose unicode code you know in a javascript string literal using \xXX.

This should work :

input = input.split("\0x1f").join('');
发布评论

评论列表(0)

  1. 暂无评论