Forum Discussion

4m4d3u5's avatar
4m4d3u5
Contributor
7 years ago

Breaking a string apart

I have a string 100C and I want to break up this string into it's two parts so that I get 100 C. What would be the best way to go about that?

 

  • In JavaScript, strings are, essentially, arrays of individual characters.  So, you could write a JavaScript routine to go through each character in the string to grab everything up to the C, place those in one string... append a space... and then append the C.

     

    Alternatively, you could use the aqString.Find method to find the location of the C, use aqString.SubString to get everything up to but not including the C and put it in one variable, append a space, and then append the C.

     

    Multiple ways... but it's going to take code of string manipulation to do so.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        In JavaScript, strings are, essentially, arrays of individual characters.  So, you could write a JavaScript routine to go through each character in the string to grab everything up to the C, place those in one string... append a space... and then append the C.

         

        Alternatively, you could use the aqString.Find method to find the location of the C, use aqString.SubString to get everything up to but not including the C and put it in one variable, append a space, and then append the C.

         

        Multiple ways... but it's going to take code of string manipulation to do so.