javascript - Dynamic regular expression -
trying make expression dynamic. can split string in equal chunks.
var keyparts = key.match(/.{1,4}/g);
var keyparts = key.match(/.{rangea,rangeb}/g);
so want make range, trying put in new regexp() w/o positive results.
try this:
var re = new regexp(".{" + rangea + "," + rangeb + "}", "g"); var keyparts = key.match(re);
demo: http://jsfiddle.net/bzkaq/
in demo, notice how when change length of key
between ranges, match string.
reference: