I am trying to separate HTML-tagName from HTML-Code. My HTML-Code is as follows:
<div id="MyDiv" style="left:100px; top:10px;" > some text in div
<strong>
<em> Some text for em
<p><b>b, <span id="MySpan">span1,
After calling of REg-Ex I expect all valid HTML-Tagname from string. E.g. from above HTML-Code it should result something as follows: div, strong, em, p, b, span. Here is my approach:
sTagName = sTagName.replace(/< *(.*) *>/, '$1');
alert(sTagName);
The above RegEx-Statement delivers for < div >
results: div
This is ok.
But it delivers for < div stlye="..." >
results: div stlye="..."
This is wrong.
I expect for it only a div
.
In other words after space in HTML-Tagname the string should be deleted, so that I get div-Tagname.
For performance reasons I won't call the RegEx-Statement twice.
Thanks in advance.