Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts

    StringBuffer help

    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

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    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
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder DELOCH's Avatar
    Join Date
    Apr 2006
    Location
    Canada
    Posts
    537
    Thanks
    4
    Thanked 2 Times in 2 Posts
    It is possible to do...

    PHP Code:
    String[] splitted;
    String a "All your base are belong to us";
    splitted a.split(" "); // function: String.split(regex) returns String[] 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •