I'm trying to split a string every n characters using a match function, but I figured that there are other uses to using a variable in a match function.
I know that the code
str.match(/.{0,3}/g);
will give me every three characters in a string, but
var n = 3;
str.match(/.{0,n}/g);
will not.