I'm trying to write a regular expression for following criteria
The source string might optionally contain an html code. Which should be preserved, everything outside tag should replace with a static text.
function replaceCode( mystring ){
var replaceWith = "Hello!!!" ;
//do something with mystring here..
}
var string1 = "<span>Title</span> A small note" ;
var string2 = "Another big note" ;
alert( replaceCode(string1) ) ;
alert( replaceCode(string2) ) ;
Resultant strings must be
//string1 must become
<span>Title</span> Hello!!!
//string2 must become
Hello!!!