Article View: borland.public.jbuilder.java.language
Article #19072Re: substring?
From: Richard Merdinger
Date: Thu, 12 Mar 1998 00:00
Date: Thu, 12 Mar 1998 00:00
38 lines
1525 bytes
1525 bytes
Just a suggestion, but why not try the StringTokenizer class? You
should be able to instantiate it and give it a number of delimiters.
Seems this class was created for just this sort of thing.
Richard Merdinger
Jomax Technologies Inc
rmerdinger@jomax.net
On Thu, 12 Mar 1998 07:55:55 +0000, Richard Evans
<evansar@genrad.co.uk> wrote:
>Mike,
>
> String temp = textField1.getText();
> myString1.setText(temp.substring(0, temp.indexOf("-")));
> myString2.setText(temp.substring(temp.indexOf("-") + 1,
>temp.indexOf(",")));
> myString3.setText(temp.substring(temp.indexOf(",") + 1,
>temp.length()));
>
>Rich Evans.
>
>
>Mike Harris wrote:
>
>> I have a string in textField1 = "ABC-123,DEF". I would like the result
>> to be 3 strings: mystring1 = "ABC", mystring2 = "123", and mystring =
>> "DEF". I am having problems with using substring and indexOf (to find
>> the positions of "-" and ","). What would be the proper syntax? Am I
>> using the correct functions?
>>
>> THANKS!
>> Mike
>
>
>
Technical Details
Message-ID:
<3508091d.164021600@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<35076C2C.77C6@harrismedia.com> <3507950B.E0E9DB41@genrad.co.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,6960f1f07e315512 X-Google-Attributes: gidf74b3,public From: rmerdinger@jomax.net (Richard Merdinger) Subject: Re: substring? Date: 1998/03/12 Message-ID: <3508091d.164021600@forums.borland.com> X-Deja-AN: 333369043 References: <35076C2C.77C6@harrismedia.com> <3507950B.E0E9DB41@genrad.co.uk> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.language