Cut part of url using jquery

Google produces thumbnails of images http://images.google.com/images?q=tbn:9vPPg9Y5ojFMeM::www.maniacworld.com/amazing-cars.jpg

I need only the main image URL, which in this case is www.maniacworld.com/amazing-cars.jpg I noticed that we have :: in front of the main image URL

What is the easiest way to do this using jquery.

+3
source share
5 answers

If you want to use jQuery, then something like this should work:

  var result = [yourstring].split("::")[1];

Working demo

0
source

You don't need jquery, you can just use regex.

var re= /.+::/
var newurl = googleurl.replace(re,'');

: http://jsfiddle.net/Rsefq/

+1
var str = 'http://images.google.com/images?q=tbn:9vPPg9Y5ojFMeM::www.maniacworld.com/amazing-cars.jpg';
alert(str.split('::')[1]);
0

JavaScript split(), , "::" , .

var parts = url.split("::");
var image_url = parts[1];
0
source

you don't need jquery, you can just use line splitting with javascript, but if you want jquery here, you go:

$('urlSelector').attr('href').split('::')[1]
0
source

Source: https://habr.com/ru/post/1788060/


All Articles