Board index » jbuilder » String.indexOf issues with : character

String.indexOf issues with : character


2003-11-01 08:03:35 AM
jbuilder12
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.
 
 

Re:String.indexOf issues with : character

I've never seen indexOf behave like that. What you're seeing suggests to me
that the source string doesn't contain the data you think it does.
--
Check out our latest white papers at
www.datadevelopment.com/papers/index.html
BladeNET Scores With Borland Enterprise Tools
Team Development with JBuilder and Borland Enterprise Server
Dolphin Data Development Ltd.
www.datadevelopment.com/
"Ron Loewy" < XXXX@XXXXX.COM >wrote in message
Quote
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.




 

Re:String.indexOf issues with : character

"Kevin Dean" < XXXX@XXXXX.COM >wrote in message
Quote
I've never seen indexOf behave like that. What you're seeing suggests to
me
that the source string doesn't contain the data you think it does.

Thanks. Actually the source string did include the string - but I was
transposing a couple of characters in the search string and somehow managed
not to see it for more than an hour...
Too much work, not enough play, I guess. Sorry for the false alarm.
Ron.
 

{smallsort}

Re:String.indexOf issues with : character

No problem. Been there, done that.
--
Check out our latest white papers at
www.datadevelopment.com/papers/index.html
BladeNET Scores With Borland Enterprise Tools
Team Development with JBuilder and Borland Enterprise Server
Dolphin Data Development Ltd.
www.datadevelopment.com/
"Ron Loewy" < XXXX@XXXXX.COM >wrote in message
Quote

"Kevin Dean" < XXXX@XXXXX.COM >wrote in message
news:3fa55492$ XXXX@XXXXX.COM ...
>I've never seen indexOf behave like that. What you're seeing suggests
to
me
>that the source string doesn't contain the data you think it does.
>

Thanks. Actually the source string did include the string - but I was
transposing a couple of characters in the search string and somehow
managed
not to see it for more than an hour...

Too much work, not enough play, I guess. Sorry for the false alarm.

Ron.