var str = '<img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; />';
var strArray = str.split('><')
var result = strArray.map(function(str) {
return str.replace(/<*img.+src\="(.+)".*/ig, '$1');
});
console.log(result);
var data = '<img alt="image" src="http://www.qqbsmall.com/data/...;" /><img alt="image" src="http://www.qqbsmall.com/data/...;" /><img alt="image" src="http://www.qqbsmall.com/data/...;" /><img alt="image" src="http://www.qqbsmall.com/data/...;" /><img alt="image" src="http://www.qqbsmall.com/data/...;" /><img alt="image" src="http://www.qqbsmall.com/data/...;" /><img alt="image" src="http://www.qqbsmall.com/data/...;" /><img alt="image" src="http://www.qqbsmall.com/data/...;" /><img alt="image" src="http://www.qqbsmall.com/data/...;" />';
var array = data.match(/(?<=src=("|'))[^"']+/g);
console.log(array)
regularization is interesting. I suggest you know
.
idea: first separate each img, intercept the string between src= "and" / > of each img, and push into the new array
for example
<img id="img1" />
document.getElementsById('img1').src
in this way, you get the strength of the road. After intercepting the part you want through the string, push goes in
.
let imgArray = [];
imgArray.push({
document.getElementsById('img1').src
})
is done
be smart:
let str = `<img alt="image" src="http://www.qqbsmall.com/data/..." /><img alt="image" src="http://www.qqbsmall.com/data/..." /><img alt="image" src="http://www.qqbsmall.com/data/..." /><img alt="image" src="http://www.qqbsmall.com/data/..." /><img alt="image" src="http://www.qqbsmall.com/data/..." /><img alt="image" src="http://www.qqbsmall.com/data/..." /><img alt="image" src="http://www.qqbsmall.com/data/..." /><img alt="image" src="http://www.qqbsmall.com/data/..." /><img alt="image" src="http://www.qqbsmall.com/data/..." />`;
let div = document.createElement('div');
div.innerHTML = str;
let src = Array.from(div.children).map(v => v.src);
console.log(src);
not as good as upstairs, not as regular as regular, stop shaking
I'll have one too.
var str = '<img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; /><img alt="image" src="http://www.qqbsmall.com/data/..."; />';
console.log(str.match(/(?<=src=")(\S*)(?=")/g));