简体   繁体   English

正则表达式或功能需要什么才能从json响应中获取数据

[英]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 我不了解正则表达式或jquery的要求是什么,或者我如何删除此&quote并获取companypageurl

you can use the regex 你可以使用正则表达式

/http:[^;]+/

 let str = '["Web Development","Professional Training","Apprenticeship","Nonprofit"],"companyPageUrl":"http://www.thedifferenceengine.io"' console.log(str.match(/http:[^;]+/)); 

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM