• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 786
  • Last Modified:

Flash AS2 how to detect HTML tags within text and remove

Hi,

I'm wanting to create a function that can search through a string and find and remove any HTML tags.
I'm thinking along the line that if I search for the first < then search for the following > and count how many characters are in between, then remove them to create the new shorter string...

so  "this text has <br/> no <strong> tags" would end up as "this text has no tags";

Could anyone offer a solution on how to achieve this please.

Thanks in advance.

Mark

0
crooksy88
Asked:
crooksy88
2 Solutions
 
CyanBlueCommented:
I guess this is what you are looking for...
http://proto.layer51.com/d.aspx?f=983

You might also want to take a look at the Regular Expression...
http://www.jurjans.lv/flash/RegExp.html

CyanBlue
0
 
quizengineCommented:
var start_tag_position:Number = 0;
test_string = "This text has <br/> no <strong> tags";
while (start_tag_position != -1) {
start_tag_position = test_string.indexOf("<",0);
      if (start_tag_position != -1) {
            //alert - tag found now search for the closing tag
            end_tag_position = test_string.indexOf(">",0);
                  if (end_tag_position != -1) {
                  test_string = test_string.substring(0,start_tag_position) + test_string.substring(end_tag_position+1)
                  }
      }
}
trace(test_string);
0
 
crooksy88Author Commented:
Thanks for your speedy responses.

The solution Cyan Blue offered did the trick and I appreciate your input quizengine.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now