Split by non-escaped colons

Discussion in 'Plugin Development' started by MCMastery, Jul 13, 2016.

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

    MCMastery

    I want to split a string by colons that do not have backslashes in front of them.

    Example:

    "this:is: a\\:cool : test" should return ["this", "is", " a\\:cool ", " test"]

    My code so far:
    Code:
    String s = "this:is: a\\:cool  : test";
    String[] split = s.split("(?!\\\\):");
    I tested the regex "(?!\\\\):" and it matches ":" but not "\:". For some reason, the value of split is [this, is, a\, cool , test]. How can I do what I want?
     
Thread Status:
Not open for further replies.

Share This Page