From: "Corey Ashford" <corSPAMey@rational.com>
Subject: Re: String Manipulation - Help Needed
Date: 1998/04/05
Date: 1998-04-05T00:00:00+00:00 [thread overview]
Message-ID: <6g941j$5a4$1@usenet.rational.com> (raw)
In-Reply-To: x3g0MCAC5AK1EwY0@roslyn.demon.co.uk
Howard Davies wrote in message ...
>Hi,
>I have a sentence stored in a string and I need to remove all spaces and
>punctuation from the string.
>My 600 page Ada book just says that this requies advanced packages that
>are beyond the scope of the book.
>Can someone help me out?
>
>Many thanks,
>--
>Howard Davies Howard@roslyn.demon.co.uk
The first idea that comes to mind is something like:
function excise_puctuations(s : string) return string is
count : natural := 0;
begin
for i in s'range loop
if not is_punctuation(s(i)) then
count := count + 1;
end if;
end loop;
declare
result : string(1..count);
idx : natural := 1;
begin
for i in s'range loop
if not is_punctuation(s(i)) then
result(idx) := s(i);
idx := idx + 1;
end if;
end loop;
return result;
end;
end excise_punctuation;
the function is_punctuation would look something like:
function is_punctuation(c : character) return boolean is
begin
return not (c in 'a'..'z') and not (c in 'A'..'Z');
end is_punctuation;
- Corey
(to send me e-mail, remove the word SPAM from my e-mail address)
next prev parent reply other threads:[~1998-04-05 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-06 0:00 String Manipulation - Help Needed Howard Davies
1998-04-05 0:00 ` Matthew Heaney
1998-04-05 0:00 ` Corey Ashford [this message]
1998-04-06 0:00 ` Michael F Brenner
1998-04-07 0:00 ` Robert Dewar
1998-04-07 0:00 ` Howard Davies
1998-04-07 0:00 ` Michael F Brenner
1998-04-07 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox