Lee <RE**************@cox.net> wrote in message news:<bq*********@drn.newsguy.com>...
Adam said:
Hi all,
If I have a string where I know the length how do I split that into an
array based on Char position.
For example, split a string with a length of 100 into a 5 element
Array, each of 20 chars length.
If you know that the string is an exact multiple of 20 characters,
you can use:
var myArray=str.match(/.{20}/g);
If the last block might have fewer, but you want all of the
others to contain 20 characters, you would use:
var myArray=str.match(/.{1,20}/g);
If neither of these will work for you, give more detail about
what you need.
Thanks for the Response Lee .
After a bit more investigation I realised what I was hoping for
wouldnt work for me anyway.
I have a <textarea> rows=5 cols=50.
I want to create an array with each element of the array to contain
the contents of each row from the <textarea>. I was expected to grab
the .innerText of the object and create a maximum of 5 strings each
with a length of 50.
But I realised that just because there is 50 cols in a row, there may
be more than 50 characters in that row.
Does anyone know how to create a an array of strings that contain the
contents of each row in a <textarea> object.
Thanks.
Adam