View Full Version : Erasing html tags

02-14-2003, 08:04 PM
If I am given any link such as:

<a href="http://blah">I want this text</a>

How do I chop off the html tags so I get just "I want this text"?

Is regular expressions the only way to accomplish this?

02-15-2003, 01:57 AM

02-26-2003, 11:01 AM
Yep - I tend to do this in javascript - have a whole host of functions like that...

Try this...

var sHTML = variableName;
sHTML = sHTML.replace(/<[^>]*>/g, "");
return sHTML;

So if you're pulling stuff from a form just call the function on submit and use the form reference instead of variable name.

If you want to do it using ASP/VBScript, go to this article of 4guys... tells you everything you need to know.



02-27-2003, 12:45 AM
Any regex that works in javascript should work pretty much exactly the same in VBScript, or C# in .NET with little or no modification. :)

Sorry I didn't elaborate more, with your experience I figured you could find plenty of examples, such as the one dominicall posted.

Strangely enough, I was working with another developer today parsing out https?\/\/\s?=\s?["']([^"'\s]*) links (something like that).