Solved Absolutely No Sense (String.split)

Discussion in 'Plugin Development' started by messageofdeath, Oct 14, 2013.

Thread Status:
Not open for further replies.
  1. Offline


    This is output from a program. (Pay attention to top two lines.)
    The top line is the input.
    The second line is what outputs with the System.out.println();

    This is the code.
    1. public static Cuboid getStringToCuboid(String cube) {
    2. System.out.println(cube.split("|")[0] + " | " + cube.split("|")[1]);
    3. return new Cuboid(Vector.getStringToVector(cube.split("|")[0]), Vector.getStringToVector(cube.split("|")[1]));
    4. }

    EDIT: Please note that [Spree] is not part of the input.
  2. Offline


    Your dealing with regexs. "|" is considered a special character. what you need to do is put "\\|" the "\\" makes it so regex is splitting | and not using it as a method.
Thread Status:
Not open for further replies.

Share This Page