I tested the regEx on RegExr and it's working but when I put it in my code nothing happens.
RegExp: https://regexr.com/3gpfu
My Code:
$('.attachment-shop_thumbnail').each(function () {
var imgsrc = $(this).attr('src');
imgsrc = imgsrc.replace('/-\d+x\d./g', '');
console.log(imgsrc);
$(this).wrap('<a href="' + imgsrc + '" rel="lightbox"></a>');
});
I tried to put it in a new variable:
var rgx = new RegExp('/-\d+x\d./g');
imgsrc = imgsrc.replace(rgx , '');
But that didnt helped at all.