For a line like ...
"ABCDEFG"
Is it possible to have a quantifier that works the other way around, so to speak?
For instance:
var foo = "ABCDEFG";
foo.match(/.{1,3}/g);
Results in:
// Array(3) ["ABC", "DEF", "G"]
What I'm trying to achieve:
// Array(3) ["A", "BCD", "EFG"]
Therefore, regardless of the length of the string, the array is always a representation of the string, with each length of node 3 characters (with the possible exception of the 1st), but always starts at the end of the string. Thus, the first element of the array can be 1, 2, or 3 characters long, simply depending on what is left.
I tried to use the following errors:
foo.match(/.{-1,3}/g); // null
foo.match(/.{1,-3}/g); // null
I think I could use negatives similar to dividing lines, however each of these examples returns null.
, - , , , .match(). , , ?