What I'm looking to do is split data from string into an array.
Here's the general idea of the text format...
xxxxx
denotes any mix of alpha-numeric-whitespace data.
xxxxx
1 xxxxxxxxxx
2 xxxxxxxxxx
xxxxxxxxx
xxxxxxxxx
xxxxxxxx
3 xxxxxxxxxx
4 xxxxxxxxxx
xxxxxxxxxx
5 xxxxxxxxxx
(When numbers get into the double digits, the ten's place goes into the blank position in-front of the number)
Now what I want to do is have an array of 5 elements (in this case), which stores the number and all data that trails (including the new lines). In the past this was not a big deal and I could use string.split("\n")
, but now I need to delimit based on some sort of regex like /\n [0-9]{1,2}/
so I'm looking for a quick and easy way to do this (as split() doesn't support regex).
I want the array to be like
array[1] = " 1 xxxxxxxxxx"
array[2] = " 2 xxxxxxxxxxx\nxxxxxxxxxx\nxxxxxxxxxx"
array[3] = " 3 xxxxxxxxxx"
...etc