+ Reply to Thread
Results 1 to 2 of 2

Thread: String manupulation on java

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    40

    String manupulation on java

    I have that string form :
    Code:
    [-0.4211954555090929, 0.7931147934115113, -0.3875088408121027, -0.09421705940705522, 0.10065554475134718, -0.22044284832864797, 0.3532556916833505, -1.8256229909222224]
    I`d like to remove these chars >> [ or ] or ,
    So the string becomes :
    Code:
    -0.4211954555090929 0.7931147934115113 -0.3875088408121027 -0.09421705940705522 0.10065554475134718 -0.22044284832864797 0.3532556916833505 -1.8256229909222224
    I tried :
    Code:
    line.replaceAll("([|]|,)$", " ");
    But it didn`t work.
    I wish you guys help me.

  2. #2
    Junior Member
    Join Date
    Feb 2012
    Posts
    19
    Please Try :
    Code:
    line = line.replaceAll("([|]|,)$", " ");
    You can actually avoid REGEX by trying the following :
    Code:
    char exchange = ' ';
    line = line.replace('[', exchange).replace(']', exchange).replace(',', exchange);

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

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