Conversion of js characters to an array

image http://www.qqbsmall.com/data/.; / > image http://www.qqbsmall.com/data/.; / > image http://www.qqbsmall.com/data/.; / > image http://www.qqbsmall.com/data/.; / > image http://www.qqbsmall.com/data/.; / > image http://www.qqbsmall.com/data/.; / > image http://www.qqbsmall.com/data/.; / > image http://www.qqbsmall.com/data/.; / > image http://www.qqbsmall.com/data/.; / >

how does this string cut out the address in src and convert it into an array

Feb.27,2021

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));
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be587f-30fcc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be587f-30fcc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?