| Author |
Playing with String
|
Steve Bradley
Greenhorn
Joined: Jun 09, 2004
Posts: 15
|
|
Hi gang, Here's one I could use some help with... I would like to create a new String object which is the value of (char's between parameters) within an existing String object so that.... I've been playing with String.toCharArray and StringBuffer objects... What is the best route to get from String a to String b?
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
Have a look at the java.util.regex package.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Matthew Taylor
Rancher
Joined: Jun 13, 2004
Posts: 110
|
|
If you don't want to mess with a StringBuffer, you can use the indexOf() and substring() methods of String. Like this: substring(int,int) takes the first and last index of the string and creates a new substring of it. So if you find the indexOf() the "(" and ")" and pass those ints to substring(int,int), you'll create the proper substring. But you have to +1 to the first index so you won't include the "(". HTH
|
Grails Consultant
http://dangertree.net
|
 |
 |
|
|
subject: Playing with String
|
|
|