It might help if I could see the data passed as htmlIMG but I think you need:
var oRE = new RegExp(tempImg, "i");
String.protoype.replace needs a regular expression as its first argument and a string as its second. It also doesn't replace inline, it trerns a new String with the new text. Regular expressions can be created quickly using the forward slash delimiters, /, but these take a string literal. You are using a variable, tempIMG so you need the two stage creation shown above. The i flag indicates case insensitive. The main problem is that if your target string contains special characters, especially back slashes, \, you need to double these up before creating the Regular Expression.
As you know where the string starts and ends it might be easier just using String methods. Concatenate the string from htmlIMG upto the start of the a tag, the new text (bioView), and add on the text after the end of the a tag.
If you show me an example of possible inputs and desired outputs perhaps I can come up with a better explanation.