This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Split and other String functions/methods

 
Miguel Enriquez
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have these code but not work in myproc2 any advices why?

NOTE: i am Delphi programmer and i need know the next other string functions:
wcade="Mycade|XXX"
1) Pos("|",wcade) return me: 7 if not exist return me a 0
2) Delete(wcade,1,2) return me: cade|XXX
in java?
[ edited to format code and to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ March 15, 2004: Message edited by: Dirk Schreckmann ]
 
Carlos Failde
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the myproc2() problem is the regex expression.
mycade.split("\\|")
will split around the | character as I guess you are trying to do.
1) Pos("|",wcade) return me: 7 if not exist return me a 0

wcade.indexOf('|');
2) Delete(wcade,1,2) return me: cade|XXX

You could put something together with substring() I guess

Note that indexing begins from 0 so I had to adjust your numbers
would return Mcade|XXX
Use the api docs for more information on String methods.
 
Miguel Enriquez
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks worked.....
much thanks
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Miguel!
I've very happy that a fellow rancher has already helped to point you in the right direction for solving your problem. I'm posting just to suggest a simple tip to help improve communications in these forums.
When posting code, please be sure to surround the code with the [code] and [/code] UBB Tags. This will help to preserve the formatting of the code, thus making it easier to read and understand.
 
Edwin Keeton
Ranch Hand
Posts: 214
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The parameter to split() is a regular expression. '|' is a regex logical operator. Change "|" to another expression, (like maybe ":") and you will get an array of strings as follows:
Chihuahua
30
Jose Alfredo Miguel
1
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic