0

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.

user7294900
  • 52,490
  • 20
  • 92
  • 189
Bill Bronson
  • 511
  • 2
  • 9
  • 22

0 Answers0