I have regular expression for extracting the source of images in html string coming from json api in react native app, that works fine. The output is in urls array:
var m,
urls = [],
str = '<img class="d-block mx-auto" src="http://www.website.com/wp-content/uploads/2020/05/66189-759x493.jpg" />,
rex = /<img[^>]+src="?([^"\s]+)"?\s*\alt="First slide">/g;
while ( m = rex.exec( str ) ) {
urls.push( m[1] );
}
console.log(urls); // ["http://www.website.com/wp-content/uploads/2020/05/66189-759x493.jpg",...]
However I want rex that gets only the source of images inside class carousel-item :
str = '<div class="carousel-item"> <img class="d-block mx-auto" src="http://www.website.com/wp-content/uploads/2020/05/66189-759x493.jpg" />';