on 04-26-2016 1:34 AM
Hi Experts, How can i convert for example (1;2;3) to Java script array [ "1" , "2" , "3" ]; Another example (1,9,12,36,25) to ["1" , "9" ,"12" ,"36" , "25" ] I will have opening and closing brackets ( , ) with 1;2;3 . so it will be (1;2;3) . Is there a Function module in Java script ? Best regards, pradeep.
Hi,
for these cases you can use a combination of the standard functions split() and substr(). For the latter, take the help of the length parameter to remove the trailing bracket.
This should do the trick (untested!)
var myText = "(1;2;3)";
var myTextContent = myText.substr(1,myText.length - 2);
var myArray = myTextContent.split(";");
Good luck!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.