regex - replace tags in javascript regexp -


i doing regexp tool, accepts input in text , showing results in div. replace matches <b>match</b> when show results. if matches raw text works fine problem when insert html code

i want replace tags except <b> tag html entities, how can achieved that?

 var regexptool = {     makeregexp: function(pattern, opts){         var regexp = new regexp(pattern, opts);         return regexp;     },     createresults: function(pattern, string, opts){         var res = string.replace(this.makeregexp(pattern, opts), "<b>$&</b>")          results.style.display = "block";         text.style.display = "none";         results.innerhtml = res;   } } 

perhaps code should more like:

var win = window, doc = document, bod = doc.getelementsbytagname('body')[0]; function e(e){   return doc.getelementbyid(e); } function regexptool(text, outputelement){   this.makebold = function(options){     outputelement.innerhtml = text.replace(new regexp('^(<.+>)*('+text+')(<\/.+>)*$', options), '<b>$2</b>')     outputelement.style.display = 'block';    }; }  new regexptool('<div>now</div>', e('wow')).makebold(); 

note, there no reason makeregexp method.

here's http://jsfiddle.net/phpglue/fjedg/2/ .

it won't work self closing tags.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -