jquery - javascript regular expression error -


i have regular expression ^<+[a-za-z=\" ]+> need replace text in string <span class="myclass">some text< /span>.

i want remove spans , some text, code:

var text = "<span class=\"myclass\">some text</span>"; var mytext = text.replace(/^<+[a-za-z=\" ]+>/,"").replace("</span>",""); 

i searched hour cant find error is. note cant type span tag made spaces in front open bracket.

and know can type:

var somevar = $(".myclass").html(); 

but need regexp, please me!

if want sitting between first > , next < can this:

var mytext = text.replace(/^[^>]*>([^<]*).*/, "$1"); 

here jsfiddle it. if want make specific span can alter leading part of regex include span.

as mentioned above, however, if doing in dom it's lot safer stick existing dom manipulation features.


Comments