I have this string
\'john smith~123 Street~Apt 4~New York~NY~12345\'
Using JavaScript, what is the fastest way to parse this into
split() method in javascript is used to convert a string to an array. It takes one optional argument, as a character, on which to split. In your case (~).
If splitOn is skipped, it will simply put string as it is on 0th position of an array.
If splitOn is just a “”, then it will convert array of single characters.
So in your case
var arr = input.split('~');
you will get name at arr[0] and street at arr1.
You can read for more detail explanation at Split on in JavaScript