comp.lang.ada
 help / color / mirror / Atom feed
From: mutilation@bonbon.net (wave)
Subject: Stripping html from a string
Date: 21 Feb 2004 16:13:59 -0800
Date: 2004-02-21T16:13:59-08:00	[thread overview]
Message-ID: <4d01ad29.0402211613.34d2ebcd@posting.google.com> (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.



             reply	other threads:[~2004-02-22  0:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-22  0:13 wave [this message]
2004-02-22  0:45 ` Stripping html from a string Georg Bauhaus
2004-02-22 11:07   ` wave
2004-02-22 16:17     ` Georg Bauhaus
replies disabled

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