5

I have a String from a tabel innerHTML where i need to remove all img tags using replace my Regex removes everthing after the first img tag my code at JSFiddle here

Zion
  • 723
  • 3
  • 7
  • 24

1 Answers1

14

Use non-greedy matching using .*?

var tmp = inner.replace(/<img .*?>/g,"REPLACED"); 

Regex Demo

nu11p01n73R
  • 26,397
  • 3
  • 39
  • 52