4 Replies Latest reply on Jun 11, 2009 3:36 AM by Achille Felicetti

    Removing tags from text

    Achille Felicetti

      Hello everybody, I am trying to create an annotation tool for tagging free text with RDF markup. I am able now to select a fragment of text and from a TextArea or RichTextEditor, pressing a button, putting tags around it . My problem is the opposite one: how can I remove the tags from the same text fragment? it is possible to add an index to a fragment of text? I found no solution right now. Any help appreciated

       

      Thanks in advance

      Ak

        • 1. Re: Removing tags from text
          leybniz Level 4

          Here is similar solution:

          http://weblogs.asp.net/rosherove/archive/2003/05/13/6963.aspx

           

          you should use RegExp class to define <(.|\n)*?>

          1 person found this helpful
          • 2. Re: Removing tags from text
            Achille Felicetti Level 1

            Dear leybniz thank you for your reply. The problem I have is not a general problem for which your solution is perfect. I want to remove tags only from a sinlge fragment of html text.

            Suppose you have a long text with many annotations. What I want to do is clicking on one piece of text already annotated and give user the possibility to remove the annotation previously inserted. My question was: how can I recognize where user had clicked? How can I find from the text into the  RichTextArea the annotation the user has selected?

             

            Thank you in advance to everybody willing to help me.

            A.

            • 3. Re: Removing tags from text
              leybniz Level 4

              I see, It seems you'd better came out with some middle-complexity algorithm finding start annotation tag first and afterwards search forward to matching closing tag.

               

              On each text change  you should (re)build tags map using regexp above, you could use Dictionary class for that purpose, something like this:

              var tagsMap:Dictionary = new Dictionary();

               

              // fill map

              tagsMap[StartTagPositionIndex] = "Tag text itself";

               

              You can trace caret move inside RichTextArea to be notified on current cursor position and if caret stands on some position which is already in your tagsMap dictionary + tag text length, and so on..

               

              OR you could go with building full tags map as associative structure matching both  begin-end tags and their details like start indexes.

               

              ofcourse it's just an insight

              • 4. Re: Removing tags from text
                Achille Felicetti Level 1

                Dear leybniz,

                Your "dictionary" solution was perfect for me, thanks a lot

                 

                Ciao

                A.