2

I am not able to remove zero width character from a string. It is no problem to remove any other character, only the '\u200B' seems to resist my tries.

I am getting strings from my API that contain zero spaces (\u200B) that are used to tell the mobile app where to break words. Now within a comparison in my web app I need to get rid of these zero spaces.

I tried

ingredient = ingredient.replace(/\u200B/g,'')

with a large 'B' and a small 'b' and the same with lodash

_.replace(ingredient, '\u200B', '');

but none of my options seem to work. Any ideas?

Sinan Theuvsen
  • 193
  • 1
  • 3
  • 14
  • Using string replace (your first code sample) worked for me. How are you checking the result? – polm23 Jun 27 '17 at 03:56
  • It was an error from the server. Some of the items had '\u200B' and some had '\\u200B'. Both are invisible and seem to be the same. I found the problem by comparing the strings and then their length. – Sinan Theuvsen Jul 05 '17 at 15:43

0 Answers0