I need to remove null bytes from a string. However, after replacing the null bytes \u0000 in the string
let data = {"tet":HelloWorld.\u0000\u0000\u0000\u0000"}
let test = JSON.parse(data).tet.replace("\u0000", "");
I always end up with the following value:
HelloWorld.[][][][]
These are not array brackets or anything like that.
All I want is the value HelloWorld. How can I achieve this?
The solution turned out to be replacing all bytes.
.replace(new RegExp("\u0000", "g"), "");