• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding string tokenizer  RSS feed

 
Prem Bhazee
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I have a written a method to return me the token of a string by specifing the token as argument in the method. for example when 2 is passed as an argument it returns me the second token. When the method is passed as 0 or more than the number of tokens I am returning null. Can you please let me know if this method breaks or fails any condition.



Here if I need to get "is" I pass 2, if i need "a" I pass 3. Was wondering does this method holds for all tokens other than 0 and greater than counttokens.

Thanks in advance.

[ February 17, 2008: Message edited by: Prem Bhazee ]
[ February 17, 2008: Message edited by: Prem Bhazee ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't worked through all the combinations, but I think basically this could be simplified to:

It's not quite equivalent, because split takes a regular expression as parameter, so not all strings can be passed into it as they are.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!