There is a script that should tear out a part of the text from the server response. But I can’t figure out the regular schedule; it only processes the first word, and then no.

Code:

+xhr.responseText.match(/_COOKIE.*?(.*?)<\/td><\/tr>/m)[1] 

Or prompt a regular schedule that ALL server answer pulled out.

It should check cookies, the line in the server response, and it needs to be received. Looks like that:

HTTP_COOKIE => __cfduid = d7a5bc6e25f6043evev21781dbb1d591bd8b1460834789; cf_clearance = b743425f1830b8averea106810887d155501c350d; 1460834814-604800; login = yXRWPuMMQ2sd dfSgc% 252F0KM985nSZ6cDNwuaFfA% 253D% 253D; password = 31567518v43v43b3975711da84e068fa78; chat_token = P38SgjlpTok4KfdfvbedfvnRKIxWuAxK4OHBkWBLnlrDe% 2BxMNQ% 3D; user_id = 78001175; real_user_id = 78001175; social_id = 296400; __auc = 333d543ga154208ab39c1e7529ec; OAGEO = NL% 7C% 7C% 7C% 7C% 7C% 7C% 7C% 7C% 7C% 7C; OAID = d4f0c5982d3sdfva46de6bf377999630; _ym_uid = 1460834849654078056; __utma = 4986037.946172708.1460834854.1460841308.1460868718.3; __utmc = 4986037; __utmz = 4986037.1460834854.1.1.utmcsr = (direct) | utmccn = (direct) | utmcmd = (none); _ym_isad = 2; __unam = 7639673-154208d00a

  • What exactly do you need? Get a response from the server? Cookies from the server? - ThisMan
  • I probably already suggested this book to everyone here - I can throw you a book on regulars for 2015 for free - on ozon it costs 2000R - if you need to write - I will fold - user33274
  • Add the initial text and the expected result - Grundy
  • This is about 10 lines in the answer, you need to tear it out of the answer. But if you are a regular member to rip out the entire answer, it will also work. In this form, + xhr.responseText does not work. But with the regular work it works, but not completely. - maximus
  • You are here it. Do not express yourself. - Sergey

2 answers 2

If I correctly understood the task, then my solution was, of course, it was possible without jQuery, but that’s not the point

 var someString = "HTTP_COOKIE => __cfduid=d7a5bc6e25f6043evev21781dbb1d591bd8b1460834789; cf_clearance=b743425f1830b8averea106810887d155501c350d-1460834814-604800; login=yXRWPuMMQ2sd dfSgc%252F0KM985nSZ6cDNwuaFfA%253D%253D; password=31567518v43v43b3975711da84e068fa78; chat_token=P38SgjlpTok4KfdfvbedfvnRKIxWuAxK4OHBkWBLnlrDe%2BxMNQ%3D; user_id=78001175; real_user_id=78001175; social_id=296400; __auc=333d543ga154208ab39c1e7529ec; OAGEO=NL%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C; OAID=d4f0c5982d3sdfva46de6bf377999630; _ym_uid=1460834849654078056; __utma=4986037.946172708.1460834854.1460841308.1460868718.3; __utmc=4986037; __utmz=4986037.1460834854.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ym_isad=2; __unam=7639673-154208d00a" var arr = someString.split(';'); arr[0] = arr[0].replace(/.*?> (.*)$/,'$1'); var arLen = arr.length; for(var i = 0; i < arLen; i++){ $('body').append(arr[i]+'</br>'); } = d7a5bc6e25f6043evev21781dbb1d591bd8b1460834789; cf_clearance = b743425f1830b8averea106810887d155501c350d-1460834814-604800; login = yXRWPuMMQ2sd dfSgc% 252F0KM985nSZ6cDNwuaFfA% 253D% 253D; password = 31567518v43v43b3975711da84e068fa78; chat_token = P38SgjlpTok4KfdfvbedfvnRKIxWuAxK4OHBkWBLnlrDe% 2BxMNQ% 3D; user_id = var someString = "HTTP_COOKIE => __cfduid=d7a5bc6e25f6043evev21781dbb1d591bd8b1460834789; cf_clearance=b743425f1830b8averea106810887d155501c350d-1460834814-604800; login=yXRWPuMMQ2sd dfSgc%252F0KM985nSZ6cDNwuaFfA%253D%253D; password=31567518v43v43b3975711da84e068fa78; chat_token=P38SgjlpTok4KfdfvbedfvnRKIxWuAxK4OHBkWBLnlrDe%2BxMNQ%3D; user_id=78001175; real_user_id=78001175; social_id=296400; __auc=333d543ga154208ab39c1e7529ec; OAGEO=NL%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C; OAID=d4f0c5982d3sdfva46de6bf377999630; _ym_uid=1460834849654078056; __utma=4986037.946172708.1460834854.1460841308.1460868718.3; __utmc=4986037; __utmz=4986037.1460834854.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ym_isad=2; __unam=7639673-154208d00a" var arr = someString.split(';'); arr[0] = arr[0].replace(/.*?> (.*)$/,'$1'); var arLen = arr.length; for(var i = 0; i < arLen; i++){ $('body').append(arr[i]+'</br>'); } % 7C% 7C% 7C% 7C% 7C% 7C% 7C% 7C% 7C% 7C; OAID = d4f0c5982d3sdfva46de6bf377999630; _ym_uid = var someString = "HTTP_COOKIE => __cfduid=d7a5bc6e25f6043evev21781dbb1d591bd8b1460834789; cf_clearance=b743425f1830b8averea106810887d155501c350d-1460834814-604800; login=yXRWPuMMQ2sd dfSgc%252F0KM985nSZ6cDNwuaFfA%253D%253D; password=31567518v43v43b3975711da84e068fa78; chat_token=P38SgjlpTok4KfdfvbedfvnRKIxWuAxK4OHBkWBLnlrDe%2BxMNQ%3D; user_id=78001175; real_user_id=78001175; social_id=296400; __auc=333d543ga154208ab39c1e7529ec; OAGEO=NL%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C; OAID=d4f0c5982d3sdfva46de6bf377999630; _ym_uid=1460834849654078056; __utma=4986037.946172708.1460834854.1460841308.1460868718.3; __utmc=4986037; __utmz=4986037.1460834854.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ym_isad=2; __unam=7639673-154208d00a" var arr = someString.split(';'); arr[0] = arr[0].replace(/.*?> (.*)$/,'$1'); var arLen = arr.length; for(var i = 0; i < arLen; i++){ $('body').append(arr[i]+'</br>'); } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 

  • Where is all this code? what is he doing? - maximus
  • Splits your string, or as you like? - sivik_xes
  • If you need to pull out the entire HTTP_COOKIE line, then I ask you to throw off what is in front of her and behind her, without this information I can’t help with the regular schedule - sivik_xes

Your regular works for the example you specify.

The request can be returned with a line break as well . not responsible for \n - line break.

If I'm right, then the following should work /_COOKIE(.|\s)*?<\/td><\/tr>/m

 function OnLoadMy(){ str="ненужный текст HTTP_COOKIE => __cfduid"+"\n"+"=d7a5bc6e25f6043evev21781dbb1d591bd8b1460834789; cf_clearance=b743425f1830b8averea106810887d155501c350d-1460834814-604800; login=yXRWPuMMQ2sd dfSgc%252F0KM985nSZ6cDNwuaFfA%253D%253D; password=31567518v43v43b3975711da84e068fa78; chat_token=P38SgjlpTok4KfdfvbedfvnRKIxWuAxK4OHBkWBLnlrDe%2BxMNQ%3D; user_id=78001175; real_user_id=78001175; social_id=296400; __auc=333d543ga154208ab39c1e7529ec; OAGEO=NL%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C; OAID=d4f0c5982d3sdfva46de6bf377999630; _ym_uid=1460834849654078056; __utma=4986037.946172708.1460834854.1460841308.1460868718.3; __utmc=4986037; __utmz=4986037.1460834854.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ym_isad=2; __unam=7639673-154208d00a</td></tr> ненужный текст"; regex =/_COOKIE(.|\s)*?<\/td><\/tr>/m; result = str.match(regex); alert("result = " + result); } n" + "= d7a5bc6e25f6043evev21781dbb1d591bd8b1460834789; cf_clearance = b743425f1830b8averea106810887d155501c350d-1460834814-604800; login = yXRWPuMMQ2sd dfSgc% 252F0KM985nSZ6cDNwuaFfA% 253D% 253D; password = 31567518v43v43b3975711da84e068fa78; chat_token = P38SgjlpTok4KfdfvbedfvnRKIxWuAxK4OHBkWBLnlrDe% 2BxMNQ% 3D function OnLoadMy(){ str="ненужный текст HTTP_COOKIE => __cfduid"+"\n"+"=d7a5bc6e25f6043evev21781dbb1d591bd8b1460834789; cf_clearance=b743425f1830b8averea106810887d155501c350d-1460834814-604800; login=yXRWPuMMQ2sd dfSgc%252F0KM985nSZ6cDNwuaFfA%253D%253D; password=31567518v43v43b3975711da84e068fa78; chat_token=P38SgjlpTok4KfdfvbedfvnRKIxWuAxK4OHBkWBLnlrDe%2BxMNQ%3D; user_id=78001175; real_user_id=78001175; social_id=296400; __auc=333d543ga154208ab39c1e7529ec; OAGEO=NL%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C; OAID=d4f0c5982d3sdfva46de6bf377999630; _ym_uid=1460834849654078056; __utma=4986037.946172708.1460834854.1460841308.1460868718.3; __utmc=4986037; __utmz=4986037.1460834854.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ym_isad=2; __unam=7639673-154208d00a</td></tr> ненужный текст"; regex =/_COOKIE(.|\s)*?<\/td><\/tr>/m; result = str.match(regex); alert("result = " + result); } 
 <!DOCTYPE html> <html> <head> </head> <body onload="OnLoadMy()"> </body> </html> 

  • And so find all regex =/[\s\S]*/; \s - all whitespace characters \S - all non-whitespace characters - Ilya