2016-07-01 2 views

答えて

0
var xhr = new XMLHttpRequest(); 
    xhr.open('GET', "https://www.googleapis.com/youtube/v3/videos?part=snippet&id=<video ID>&fields=items/snippet/title,items/snippet/description&key=<API key>"); 
    xhr.send(); 
    xhr.onreadystatechange = function() { 
      if (xhr.readyState == 4 && xhr.status == 200) { 
        var response = JSON.parse(xhr.responseText); 
       // console.log("Description:", response.items[0].snippet.description); 
       // var text = response.items[0].snippet.description; 
        var text = "Find me at sand also at fgdyh thrj hrtyrt fhrtgh"; 
        var html = findUrls(text); 
        function findUrls(text) { 
        var source = (text || '').toString(); 
        var urlArray = []; 
        var url; 
        var matchArray; 
        // Regular expression to find FTP, HTTP(S) and email URLs. 
        var regexToken = /(((ftp|https?):\/\/)[\-\[email protected]:%_\+.~#?,&\/\/=]+)|((mailto:)?[_.\w-][email protected]([\w][\w\-]+\.)+[a-zA-Z]{2,3})/g; 
        // Iterate through any URLs in the text. 
        while ((matchArray = regexToken.exec(source)) !== null) { 
         var token = matchArray[0]; 
         urlArray.push(token); 
        } 
関連する問題