Forums Register Login

Playing with String

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
Have a look at the java.util.regex package.
+Pie Number of slices to send: Send
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
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 930 times.
Similar Threads
(WhatIsThis)ab.remove(0); // Syntax question
about the javaString
Regular expression to compare numbers
Long(String s) and valueOf(String s)
trouble setting a Boolean parameter
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 04:43:08.