Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
Thread: StringBuffer help
11-24-2008, 02:20 PM #1
- Join Date
- Jan 2007
- Thanked 0 Times in 0 Posts
So i'm supposed to take a string and input it into a stringbuffer function. I was told to split the string up using stringbuffer but how do i go about doing this? I need to get each individual word in the string and then put that word into a function in order to change that individual word.
Any ideas on how to use stringbuffer to get each different word?
I tried putting the string into an array and using split but apparently I am supposed to use stringbuffer to get the juice.
Any help is appriciated
11-24-2008, 03:46 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,660 Times in 2,629 Posts
Are you sure its a string buffer you want? I'm thinking you want to tokenize you're string, or use a matcher on it. String buffer isn't all that great at finding things, but it is good for slicing and replacing...
StringTokenizer defaults its deliminter on a whitespace, so thats probably what you want to use. Combine that with a string builder and you can replace and append what you're looking to do.
Oh yes, stringTokenizer class is here
header('HTTP/1.1 420 Enhance Your Calm');
11-25-2008, 03:19 AM #3
It is possible to do...
String a = "All your base are belong to us";
splitted = a.split(" "); // function: String.split(regex) returns String