From: Simon Johnston <skj@ACM.ORG>
Subject: Re: Help me parse a long character
Date: 1997/11/03
Date: 1997-11-03T00:00:00+00:00 [thread overview]
Message-ID: <01BCE863.95E32930.skj@acm.org> (raw)
Use the Index function in Ada.Strings.Fixed, like so: the first bit will
get you the last name, and then the first name. You can then use the
resulting four values to substring your original to get two shorter
strings. Note this relies on at least one space between LASTNAME and
FIRSTNAME and a trailing space after FIRSTNAME - if this is not the case
then you'll have to add some code :)
declare
Start_Of_LASTNAME : Natural;
End_Of_LASTNAME : Natural;
Start_Of_FIRSTNAME : Natural;
End_Of_FIRSTNAME : Natural;
begin
Start_Of_LASTNAME := Full_Name_String'First;
End_Of_LASTNAME :=
Natural'Pred(Ada.Strings.Fixed.Index(Full_Name_String, " "));
Start_Of_FIRSTNAME :=
Ada.Strings.Fixed.Index_Non_Blank(Full_Name_String(End_Of_LASTNAME ..
Full_Name_String'Last));
End_Of_FIRSTNAME :=
Natural'Pred(Ada.Strings.Fixed.Index(Full_Name_String(Start_Of_FIRSTNAME ..
Full_Name_String'Last)));
end ;
-----Original Message-----
From: DHBemis [SMTP:dhbemis@AOL.COM]
Sent: Saturday, October 25, 1997 8:48 PM
To: INFO-ADA@LISTSERV.NODAK.EDU
Subject: Help me parse a long character
This is an easy one I'm sure. I'm in my first semester of programming....
I'm trying to parse a 40-character long string. They are formatted in the
following way:
LASTNAME^^^^^^^^^^^^^^^^^FIRSTNAME^^^^^^ <--- the variable Full_Name
I'm not sure how to parse it into to two separate variables, first_name and
Last_name.
I used the get_line procedure to get the string, so I have the
last_character
position. How do I ignore the spaces in between?
Thanks !
Help
next reply other threads:[~1997-11-03 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-11-03 0:00 Simon Johnston [this message]
1997-11-03 0:00 ` Help me parse a long character Robert Dewar
-- strict thread matches above, loose matches on Subject: below --
1997-11-03 0:00 Marin David Condic, 561.796.8997, M/S 731-96
1997-10-25 0:00 DHBemis
1997-10-26 0:00 ` Tom Moran
1997-10-27 0:00 ` DHBemis
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox