From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_05,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,52b8231e55574793 X-Google-Attributes: gid103376,public From: "Corey Ashford" Subject: Re: String Manipulation - Help Needed Date: 1998/04/05 Message-ID: <6g941j$5a4$1@usenet.rational.com>#1/1 X-Deja-AN: 341193561 References: X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Organization: Rational Software Newsgroups: comp.lang.ada Date: 1998-04-05T00:00:00+00:00 List-Id: 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)