Results 1 to 7 of 7
  1. #1
    jainanuj82 is offline Member
    Join Date
    Jun 2010
    Posts
    1
    Rep Power
    0

    Default Issue with String tokenizer..

    hi

    i want to break the following string..

    "a|^|aa|b|^|bb|cc^c"


    by using "|^|" ..

    i used the StringTokenizer class to do this by giving the "|^|", as Delimiter.

    But when it runs it gives completely different result than I expected
    that is it was matched any character that the delimiter include..

    I want the output as [a,aa|b,bb|cc^c]

    So please anyone can help me to do this

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Use String.split()
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Java Code:
    stringArray[] = stringVar.split("\\|\\^\\|");
    Edit: Too slow, and a bit too "revealing". ;-) I just don't feel like going through the 20 post conversation of begging for the regex.

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Quote Originally Posted by masijade View Post
    I just don't feel like going through the 20 post conversation of begging for the regex.
    You lazy sod ;)

    And he's frikken crossposter too!
    http://forums.sun.com/thread.jspa?threadID=5442913
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by PhHein View Post
    You lazy sod ;)
    Ain't I just! ;-)
    And he's frikken crossposter too!
    Java Programming - Issue with String tokenizer..
    I just saw that, too. :-|

  6. #6
    JvlShz is offline Member
    Join Date
    Jun 2010
    Posts
    26
    Rep Power
    0

    Default

    Use:

    String.split(Pattern.quote("|^|"))

  7. #7
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    You are a day late.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. String Tokenizer
    By hussainian in forum Advanced Java
    Replies: 1
    Last Post: 03-16-2010, 08:58 AM
  2. String Tokenizer
    By viperlasson in forum New To Java
    Replies: 1
    Last Post: 03-09-2010, 01:14 PM
  3. String Tokenizer
    By redasu in forum Advanced Java
    Replies: 4
    Last Post: 02-19-2010, 03:30 AM
  4. Manipulating String Tokenizer
    By Bomber_Will in forum New To Java
    Replies: 2
    Last Post: 04-19-2009, 11:54 PM
  5. string tokenizer
    By twinytwo in forum New To Java
    Replies: 2
    Last Post: 03-26-2009, 02:10 PM

Posting Permissions

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