lim kk wrote:Thank you so much Sean! It works.
I was still trying hard using .indexOf.
Thank you so much!
You're welcome. Glad that helped.
You probably could get it to work with indexOf, but the problem is you would only be able to do it on this "one" particular string since you need to know ahead of time the string that you are searching for. Using StringTokenizer will work for any generic string with the format "st,X=Y " so it can have any number of strings with different values and it will still work as long as it is in that format that you specified.
But StringTokenizer is legacy code, which you ought not to use.
How about splitting on "\\sst,\\d+=" in the String.split method? You may have to escape the = to \\=, since = is a meta-character.
Joined: Oct 13, 2005
You can also seek the indices of = and s, and take substrings. Beware of seeking an index. If you find the index of something is 123, and seek for indexOf(something, 123), you will get 123. For subsequent matches, start from 124.
Joined: Oct 14, 2011
Thank you Harsha and Campbell, I will certainly look into that. Very much appreciated!
Really need to polish up both the knowledge and skill on Java..
Thanks a lot again Sean!