regexp
![]() ![]() |
While I was trying to make this work with html5's video tag (see relevant discussion) I noticed that there were some regexp instructions that could be simplified a little. Here's the original:
vidurls = urlmap.split(/\%2C[0-9]+\%7C/);
vidformats = urlmap.match(/[0-9]+(?=\%7C)/g);
for (var i=0; i<vidurls.length; i++)
{
vidurls[i] = vidurls[i].match(/(http.*)/)[0];
vidurls[i] = unescape(vidurls[i]);
}
And here's what I think is a somewhat improved version: urlmap = unescape(urlmap); vidurls = urlmap.split(/,?\d+\|/); vidurls.shift(); vidformats = urlmap.match(/\d+(?=\|)/g); Note: the |

