MK12
MK12

Reputation: 491

what regex or functionality require to get the data from json response

$.ajax({
    url: link,   //https://www.linkedin.com/company/666511/
    type: 'GET',
    success: function (data) {
console.log(data)

//response comes in 2000 lines  
here is the sample short response

["Web Development","Professional Training","Apprenticeship","Nonprofit"]
,
"companyPageUrl":"http://www.thedifferenceengine.io"

//i only want this link to return
http://www.thedifferenceengine.io
}
});

i dont understant what regex or jquery require or how i remove this &quote and get companypageurl

Upvotes: 0

Views: 34

Answers (2)

Zigri2612
Zigri2612

Reputation: 2310

 var decode ='["Web Development","Professional Training","Apprenticeship","Nonprofit"],"companyPageUrl":"http://www.thedifferenceengine.io"';

 alert($("<div/>").html(decode).text());

Upvotes: 0

marvel308
marvel308

Reputation: 10458

you can use the regex

/http:[^;]+/

let str = '[&quot;Web Development&quot;,&quot;Professional Training&quot;,&quot;Apprenticeship&quot;,&quot;Nonprofit&quot;],&quot;companyPageUrl&quot;:&quot;http://www.thedifferenceengine.io&quot;'

console.log(str.match(/http:[^;]+/));

Upvotes: 2

Related Questions