Article View: borland.public.jbuilder.java.api
Article #394String.indexOf issues with : character
From: Ron Loewy
Date: Sat, 01 Nov 2003 00:03
Date: Sat, 01 Nov 2003 00:03
29 lines
1837 bytes
1837 bytes
Hi,
I am using JBuilder 4 (I know, it is old) and java -version returns the
following:
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
I have an issue when searching for a substring using the indexOf method of
the String class, when the : character exists.
For example - I have a very long string that in it has the substring
[:FirstDateStr]
When I search for FirstDateStr or FirstDateStr]
(Source.indexOf("FirstDateStr]") - I get the value 424
When I search for :FirstDateStr or :FirstDateStr]
(Source.indexOf(":FirstDateStr]") - I get the value -1
Here is the crazy stuff -
When I search for [FirstDateStr] (Source.indexOf("[FirstDateStr]") I get 423
It seems as if the : is ignored in the source string, but not in the
substring I am searching for.
Any ideas what I am doing wrong?
Thanks,
Ron.
Technical Details
Message-ID:
<3fa2f859$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,71d980371de077c8,start X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2003-10-31 16:09:18 PST From: "Ron Loewy" <nospam@spam.com> Newsgroups: borland.public.jbuilder.java.api Subject: String.indexOf issues with : character Date: Fri, 31 Oct 2003 16:03:35 -0800 Lines: 33 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 66.12.226.26 Message-ID: <3fa2f859$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1067645017 66.12.226.26 (31 Oct 2003 16:03:37 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail