I take user-input (JS code) and execute (process) them in realtime to show some output.
Sometimes the code has those zero width space, it's really weird. i don't know how the users are input'ing that. Example - "
($".length === 3
Unicode has the following zero-width characters:
var userInput = 'a\u200Bb\u200Cc\u200Dd\uFEFFe'; console.log(userInput.length); // 9 var result = userInput.replace(/[\u200B-\u200D\uFEFF]/g, ''); console.log(result.length); // 5
Note that there are many more symbols that may not be visible. Some of ASCII’s control characters, for example.