javascript – using regular expression to remove certain tags from string
From today, I am trying to post again on a regular basis
Here is a one line regular expression to remove a particular html tag from a string.
In the example given below I am stripping the span tags from the given string.
<script language="javascript">
linkText = '<a href="test.html"><span><span class="random">Hello World</span></span></a>'
alert(linkText);
linkText = linkText.replace(/<[\/]{0,1}(span|SPAN)[^><]*>/g,"");
alert(linkText);
</script>
Advertisement
Thanks.
Do u know how to relplace any tag with it’s content ?