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.
If you want to use jQuery, then something like this should work:
var result = [yourstring].split("::")[1];
Working demo
You don't need jquery, you can just use regex.
var re= /.+::/ var newurl = googleurl.replace(re,'');
: http://jsfiddle.net/Rsefq/
var str = 'http://images.google.com/images?q=tbn:9vPPg9Y5ojFMeM::www.maniacworld.com/amazing-cars.jpg'; alert(str.split('::')[1]);
JavaScript split(), , "::" , .
split()
var parts = url.split("::"); var image_url = parts[1];
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]
Source: https://habr.com/ru/post/1788060/More articles:Exclude tag from regex not remove from text? - regexMap a secondary domain to a subdirectory using mod_rewrite - dnsPython Regex quick question: matching negative character sets - pythonSystem.Linq.Dynamic not working for Entity Framework - dynamicView Tomcat context startup exceptions in IDEA - intellij-ideaIntelliJ IDEA Scala plugin problem - scalaC # HttpListener Cookies expiring after a session, even if the expiration time is set - c #manually draw a cluster using markerclusterer for v3 maps - javascriptЭффективно рассчитывать процент появления в MongoDB - databaseQTP find object in browser frame in java frame in IE window? - javaAll Articles