String has hidden characters, Can't able to verify ,

一笑奈何 提交于 2019-12-08 03:08:26

问题


I asked a question some 2 hours before

[Not required to see the question, Just a reference ] Storing images using node.js gives error

The solution given was was literally the same of my code, I tried to find the difference between my code and his code to see what's the modification he did to make it work, But there is nothing modified.

So i thought of trying it online IDE and i tried c9.io online IDE to check it. But suddenly something showed up little bit strange in the online c9.io IDE which my local sublime editor did't show it.

The below image is text which i saw in sublime, Which does't have any difference.

-

The below is the text i found in c9.io . As you can see clearly there is two dots showed up newly in c9.io javascript editor.

I could not able to see the difference that in normal text editor, Then in online different checker also showed the error.

Ths below is the text which has the hidden difference between two strings

AybükeArslan‌​_(3).JPG

AybükeArslan_(3).JPG

Just copy paste the above text in https://www.diffchecker.com/ after then you could see the difference between the above two strings

Can anyone tell what's the reason for this and how to remove the unwanted characters from the string through a javascript function. It's been giving one hell of a problem for 5 hours in my server.


回答1:


There are 2 Unicode characters between the n and the _, a ‌ zero width non-joiner followed by a zero width space.

Seeing them will depend on the editor/font you use and how it decides to display this class of non-printable character - if at all.

To remove them:

newStr = oldStr.replace(/[\u200c\u200b]/g, "");


来源:https://stackoverflow.com/questions/38103787/string-has-hidden-characters-cant-able-to-verify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!