javascript - How to use JS Regex for getting value of query from a google query link? (Chrome Extension) -
i have data has links browser history. want find out links of google queries , more specifically, in queries contain keyword meaning.
have tried far.
function extractdatafromhistory(){ //document.getelementbyid('history').innerhtml = "hi"; chrome.history.search({text: "", maxresults: 1000}, function(historyitems){ var data = ''; for(var i=0; i<historyitems.length; i++){ var url = historyitems[i].url; if(url.indexof('google')>-1 && url.search('q=')){ //data += historyitems[i].url.indexof('google'); data += url; } } document.getelementbyid('history').innerhtml = data; }); } the sample data get:
https://www.google.co.in/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=utf-8#q=js%20regex%20match
try regex:
'google.+q=(.+?)&' the part in parenthesis search query.
Comments
Post a Comment