If you have a well formatted text string with comma separated numbers,
like this '123,456,789'
This should have no spaces or tabs,
Then you can convert it simply into a JavaScript array.
var myTextwithNuumbercodes='123,456,789';
var numbercodes=myTextwithNuumbercodes.split(',');
returns ['123','456','789']
if you have a JSON string like this '[123,456,789]' then you get a javascript array by calling JSON.parse(theJSONString)
var numbercodes=JSON.parse('[123,456,789]');
returns [123,456,789]
notice the "[]" in the string ... that is how you pass a JSON array
toconvert it back to a string you can use JSON.stringify(numbercodes);
if you have a total messed up text then it's hard to convert it into a javascript array
but you can try with something like that
var numbercodes='123, 456, 789'.replace(/\s+/g,'').split(',');
this firstly removes the spaces between the numbers and commas and then splits it into a javascript array
in the first and last case you get a array of strings
u can transform this strings into numbers by simply adding a + infront of them if you call them like
mynumbercode0=(+numbercodes[0]);// () not needed here ...
in the 2nd case you get numbers
if you want to convert an array to a string you can also use join();
[123,456,789].join(', ');