I am really stuck with regexp replace.
I want to replace a string after checking it is valid by passing the values to a function.

The string is '<img width="300" height="300">'

var text = '<img width=300 height=300>';
text = text.replace(/<img width\=(.*?) height\=(.*?)>/gi, check_img($1, $2));
The $1 and $2 values are not being passed to the function.
This same method works in PHP by the e Modifier but not in JS.

Please Help.