Similar to String split & join, but for Javascript:
I have an Array of strings. I need to be able to join the items into one string and afterwards split that string again to get the original string collection. However, each string may contain the joining string as well, so I’ll have to do some escaping. Are there any recipes on how to achieve that?
Here is an example:
serialized = ["Hello", ",", "World"].join(",") # Nice would be "Hello,\,,World"
But
serialized.split(",")
returns ["Hello", "", "", "World"] instead of ["Hello", ",", "World"]
Doing it manually I came up with this, in case anyone ever stumbles on this again 😉
PoC: