wood burning stoves 2.0*
The moose likes Java in General and the fly likes Playing with String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Playing with String" Watch "Playing with String" New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Playing with String
 
Similar Threads
Long(String s) and valueOf(String s)
(WhatIsThis)ab.remove(0); // Syntax question
Regular expression to compare numbers
about the javaString
trouble setting a Boolean parameter