I need to match and expand a tiny url with javascript:
No luck with
text.match(/http:\/\/t\.co.*/i)
I need to match and expand a tiny url with javascript:
No luck with
text.match(/http:\/\/t\.co.*/i)
You can use code like this to capture just the tiny URL code:
var url = "http://t.co/qJEZPFk";
var matches = url.match(/http:\/\/t\.co\/([^\/]+)\/?$/);
if (matches && matches.length > 1) {
var urlCode = matches[1];
}
By way of explanation, the regex pattern is this: