Splitting strings

Discussion in 'Java' started by davidjohnlong@googlemail.com, Mar 30, 2006.

  1. Guest

    Hi

    Wondered if anyone can help

    I'm trying to split the following string into various different
    section?

    BREW coffee://localhost/pot-1 HTCPCP/0.1accept-additions:
    2*Cream,2*Vanilla,*,*,2*Whisky

    after : first varible
    then 2nd, 3rd, 4th 5th after comma

    (trying in impliment RFC 2324... )

    Thanks
     
    , Mar 30, 2006
    #1
    1. Advertising

  2. Alex Hunsley Guest

    wrote:
    > Hi
    >
    > Wondered if anyone can help
    >
    > I'm trying to split the following string into various different
    > section?
    >
    > BREW coffee://localhost/pot-1 HTCPCP/0.1accept-additions:
    > 2*Cream,2*Vanilla,*,*,2*Whisky
    >
    > after : first varible
    > then 2nd, 3rd, 4th 5th after comma
    >
    > (trying in impliment RFC 2324... )
    >
    > Thanks


    Use StringTokenizer.
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/StringTokenizer.html

    This sort of question is more suited to comp.lang.java.help as it's a
    simple question. Also you could have tried googling for "java string
    splitting" or similar, which would probably have given you the answer.
     
    Alex Hunsley, Mar 30, 2006
    #2
    1. Advertising

  3. IchBin Guest

    Alex Hunsley wrote:
    > wrote:
    >> Hi
    >>
    >> Wondered if anyone can help
    >>
    >> I'm trying to split the following string into various different
    >> section?
    >>
    >> BREW coffee://localhost/pot-1 HTCPCP/0.1accept-additions:
    >> 2*Cream,2*Vanilla,*,*,2*Whisky
    >>
    >> after : first varible
    >> then 2nd, 3rd, 4th 5th after comma
    >>
    >> (trying in impliment RFC 2324... )
    >>
    >> Thanks

    >
    > Use StringTokenizer.
    > http://java.sun.com/j2se/1.4.2/docs/api/java/util/StringTokenizer.html
    >
    > This sort of question is more suited to comp.lang.java.help as it's a
    > simple question. Also you could have tried googling for "java string
    > splitting" or similar, which would probably have given you the answer.


    Or take a look at String Class Split(). I think Sun is moving away from
    StringTokenizer.

    String[] stringVar.split(String regex) Splits this string around
    matches of the given regular expression.

    String[] stringVar.split(String regex, int limit) Splits this string
    around matches of the given regular expression.

    Then you use the the new 1.5 The For-Each Loop.

    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA
    http://weconsultants.servebeer.com/JHackerAppManager
    __________________________________________________________________________

    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
     
    IchBin, Mar 30, 2006
    #3
  4. Oliver Wong Guest

    <> wrote in message
    news:...
    > Hi
    >
    > Wondered if anyone can help
    >
    > I'm trying to split the following string into various different
    > section?
    >
    > BREW coffee://localhost/pot-1 HTCPCP/0.1accept-additions:
    > 2*Cream,2*Vanilla,*,*,2*Whisky
    >
    > after : first varible
    > then 2nd, 3rd, 4th 5th after comma
    >
    > (trying in impliment RFC 2324... )


    Are you expecting the the above as one long string? Note that the ':'
    appears twice in it.

    I'd expect some newline characters to be present, as in:

    <2324 request>
    BREW coffee://localhost/pot-1
    HTCPCP/0.1
    accept-additions: 2*Cream,2*Vanilla,*,*,2*Whisky
    </2324 request>

    - Oliver
     
    Oliver Wong, Mar 30, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. leni
    Replies:
    3
    Views:
    961
    Dag Sunde
    Aug 7, 2005
  2. John Ericson
    Replies:
    0
    Views:
    448
    John Ericson
    Jul 19, 2003
  3. Mark
    Replies:
    0
    Views:
    458
  4. John Dibling
    Replies:
    0
    Views:
    433
    John Dibling
    Jul 19, 2003
  5. Ben

    Strings, Strings and Damned Strings

    Ben, Jun 22, 2006, in forum: C Programming
    Replies:
    14
    Views:
    810
    Malcolm
    Jun 24, 2006
Loading...

Share This Page