comp.lang.ada
 help / color / mirror / Atom feed
* Stripping html from a string
@ 2004-02-22  0:13 wave
  2004-02-22  0:45 ` Georg Bauhaus
  0 siblings, 1 reply; 4+ messages in thread
From: wave @ 2004-02-22  0:13 UTC (permalink / raw)


Hello, I was wondering if anybody knew of a function lying around that
would return a given string with any html tags in it stripped.

I've had a look at Gnat.regexp, but for some reasons it's not liking
my regular expressions at all which 'should' strip the html.

Here is some of my example code:


with Ada.Text_Io, Gnat.Regexp;
use Ada.Text_Io, Gnat.Regexp;

procedure Regex is 

   procedure Testmatch (
         Re : Regexp; 
         S  : String  ) is 
   begin
      if Match( S, Re ) then
         Put_Line( S & " matches the expression" );
      else
         Put_Line( S & " doesn't match the expression" );
      end if;
   end Testmatch;

   Criteria : Regexp;  

begin
   Put_Line( "This program demonstrates GNAT's regular expression" );
   Put_Line( "capabilities. These are used to find text that match" );
   Put_Line( "a certain pattern." );
   New_Line;
  
   Criteria := Compile("<([A-Z][A-Z0-9]*)[^>]*></\1>", False, True);
   
   Testmatch( Criteria, "hello world" );
   Testmatch( Criteria, "<a
href=""http://www.helloworld.org/"">hello</a>" );
   Testmatch( Criteria, "<b>hello, world</b>" );
   Testmatch( Criteria, "some random text" );


end Regex;


Any input in this matter would be greatly appreciated.


Mut.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-02-22 16:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-22  0:13 Stripping html from a string wave
2004-02-22  0:45 ` Georg Bauhaus
2004-02-22 11:07   ` wave
2004-02-22 16:17     ` Georg Bauhaus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox