I am trying to use split() to get this output:
Colour = "Red/White/Blue/Green/Yellow/"
Colour = "Orange"
...but could not succeed. What am I doing wrong?
Basically I am matching the last / and splitting the string there.
String pattern = "[\\/]$";
String colours = "Red/White/Blue/Green/Yellow/Orange";
Pattern splitter = Pattern.compile(pattern);
String[] result = splitter.split(colours);
for (String colour : result) {
System.out.println("Colour = \"" + colour + "\"");
}