Reputation: 329
The system I'm using occasionally adds the full path to the src of a dynamic img.
<a href="#" class="link">
<img src="http://www.domain.com/images/wish-add.png" alt="" />
</a>
I need everything before /images to to be removed.
I need be able to do it without manually referencing the domain. The domain is not always going to be the same.
I can remove parts that are always the same.. Like /images.. but I don't know how to remove anything before /images regardless of what it is.
Upvotes: 1
Views: 385
Reputation: 219920
$('img').attr('src', function (i, src) {
return src.replace(/https?:\/\/[^\/]+/, '');
});
Upvotes: 3