Is there a function to separate strings?

For example I have seconds in a string for example strSec = "23". How can I draw the 2 and 3 is separate positions? Ta.
  • Former Member
    Former Member over 10 years ago
    You can use Lang.String.substring(startIndex, endIndex), where startIndex is included and endIndex is excluded, both are zero based.
    So:

    var two = strSec.substring(0,1);
    var three = strSec.substring(1,2);


    I don't think you should use this to split numbers though. See next example:

    var sec = 23;
    var two = sec / 10;
    var three = sec % 10;


    And then you can use format function to make a string if you want.