I need to replace the unicode characters defined on here
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,'')
Result - Hellothisisatestofthesite
I only want to remove the unicode character which is U+2003 between 'test' and 'of' in the string.
Use the replaceAll() method to replace a character with a space. The method takes the character to be replaced and the replacement string as parameters, e.g. str. replaceAll('_', ' ') . The method returns a new string with all occurrences of the character replaced by the provided replacement.
If you want to use space, just assign space = u" " . Try to avoid mixing byte strings and Unicode, use u" ".
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,'');
try this:
var str = "Hello this is a test of the site";
str= str.replace(/[\u00A0\u1680\u180e\u2000-\u2009\u200a\u200b\u202f\u205f\u3000]/g,'')
same as you did, but with out ' ' (regular space)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With