Reputation: 2845
I have a string that contains HTML image elements that is stored in a var. I want to remove those image elements that has alt="today" and leave the rest of images untouched .
<img src="./images/ok.gif" alt="today" />
I have tried:
var replaced2 = content.replace(/\<img src="./images/ok.gif" alt="today" />\/g,'');
but had no luck. Can anyone help me out at all? Thanks
Upvotes: 0
Views: 324
Reputation: 10398
You don't need a RegExp:
var replaced2 = content.replace('<img src="./images/ok.gif" alt="today" />','');
Upvotes: 2
Reputation: 1325
Try this as your regular expression:
/<img src=".\/images\/ok.gif" alt="today" \/>/g
Gotta make sure to escape any forward slashes because they denote a regexp
/<regexp syntax>/
Upvotes: 1