I was looking for examples in Javascript to get grouped regular expressions into an array. Say a time string which I am collecting hour, min, and sec with a regular expression. I could do it in perl in a easy way, Something like this:
$_ = "10:23:25" if (/(..):(..):(..)/) { @t = ($1, $2, $3); }But in javascript looks like there is no such way. the only way you could collect that is using the String.replace() and running the RE on it. Something like this.
str = "10:23:25" re = /(..):(..):(..)/ hr = str.replace(re,"$1"); min = str.replace(re,"$2"); sec = str.replace(re,"$3"); t = new Array(hr, min, sec);If you know of some other way, let me know :)