...

View Full Version : Erasing html tags



arnyinc
02-14-2003, 07: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?

whammy
02-15-2003, 12:57 AM
Yes.

dominicall
02-26-2003, 10: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.

http://www.4guysfromrolla.com/webtech/073000-1.shtml

dominicall

whammy
02-26-2003, 11:45 PM
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).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum