本文介绍了替换unicode空格字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要替换

我到目前为止已经有了这个,但它似乎删除了所有空间,包括标准空格键:

I have got this so far but it seems to remove all space including standard spacebar ones:

var str = "Hello this is a test  of the site";
str= str.replace(/[ \u00A0\u1680​\u180e\u2000-\u2009\u200a​\u200b​\u202f\u205f​\u3000]/g,'')

结果 - Hellothisisatestofthesite

Result - Hellothisisatestofthesite

我只想删除字符串中'test'和'of'之间的U + 2003的unicode字符。

I only want to remove the unicode character which is U+2003 between 'test' and 'of' in the string.

推荐答案

删除模式中第一个的常规空间:

Remove the regular space that you have first in the pattern:

 str = str.replace(/[\u00A0\u1680​\u180e\u2000-\u2009\u200a​\u200b​\u202f\u205f​\u3000]/g,'');

这篇关于替换unicode空格字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 13:05
查看更多