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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5e9097cf4f3eaf57 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.74.201 with SMTP id w9mr8854240pbv.0.1333441602550; Tue, 03 Apr 2012 01:26:42 -0700 (PDT) Path: r9ni13048pbh.0!nntp.google.com!news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Checking to see if a string is a letter Date: Tue, 03 Apr 2012 09:26:40 +0100 Organization: A noiseless patient Spider Message-ID: References: <2030859.0.1333426683573.JavaMail.geo-discussion-forums@pbbnv8> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="31573"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+KXgD2Gnu3X7HNeY7u8PtrxtnDMXEgZWY=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:m7aJzxDT7euwDaR2tFTANf4FGTU= sha1:hcp4OYr1IMuADwoCWQzgQOHBlLY= Content-Type: text/plain; charset=us-ascii Date: 2012-04-03T09:26:40+01:00 List-Id: deuteros writes: > On Tue 03 Apr 2012 01:15:27a, Jeffrey Carter > wrote in > news:jle13q$ale$1@tornado.tornevall.net: > >> What do you mean by "contains a single letter"? > > I mean the string contains a single letter and nothing more. For > example: > > a - Legal > A - Legal > aa - Illegal > a1 - Illegal Then for a start the length of the string needs to be 1. If it is, the first (and only!) character needs to be a lower- or upper-case letter. There are (at least) three ways of doing this: * declare an array of Boolean indexed by Character, with the elements indexed by letters set to True and the others to False, and index by the character to be tested; * declare two subtypes of character ("Character range 'a' .. 'z'", for instance) and check whether the character to be tested is 'in' either of the subtypes; * use the standard library, Ada.Characters.Handling.Is_Letter (probably the easiest for you!)