I'm trying to split a string on every 2 numbers. I presumed the
following would be fine, but I get nothing.
var re = /[0-9]{8}/;
var regex = new RegExp(re);
if(date.match(r egex)) {
var dateArray = new Array(4);
dateArray = date.split(/[0-9]{2}/);
date = dateArray[1];
date += "/" + dateArray[2];
date += "/" + dateArray[3];
}
date begins as something like "20040818" and so it matches the first
regex but then it all goes wrong somewhere. What's the best way to do
what I'm trying to do?
Thanks in advance,
Stuart.
following would be fine, but I get nothing.
var re = /[0-9]{8}/;
var regex = new RegExp(re);
if(date.match(r egex)) {
var dateArray = new Array(4);
dateArray = date.split(/[0-9]{2}/);
date = dateArray[1];
date += "/" + dateArray[2];
date += "/" + dateArray[3];
}
date begins as something like "20040818" and so it matches the first
regex but then it all goes wrong somewhere. What's the best way to do
what I'm trying to do?
Thanks in advance,
Stuart.
Comment