JRS: In article <cf**********@news.astound.net>, dated Tue, 17 Aug 2004
19:42:55, seen in news:comp.lang.javascript, Stuart Gilbert <stu-
as*****@better.domain.name> posted :
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(regex)) {
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?
By reading the newsgroup FAQ, thoughtfully; see below.
It points you to a site which includes date input, with/without
validation.
If your needs are as you indicate, and no more, then Lasse's answer
should be all the guidance you need.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.