I know how to do this in php, but I need this to be done in javascript/jquery.
I'm trying to something like the following:
$('#NewBox').html( $('#OldBox').html().Replace('/<img(.*)alt="(.*)"\>/g', "$2") );
I don't think javascript has a preg_replace, and all I know of is the replace method. using "g" should replace all instances with the 2nd parameter from the regex (being alt). Any idea why this isn't working?
UPDATE: (hopefully this better understands what I want)
I have a string such as this:
var str = 'This is a string with <img src="./images/logo.png" alt="logo" /> an image'
I want to replace all tags inside of that string with the alt so it's now:
'This is a string with logo an image'