public static void main(String[] args) { String word="101:102 5"; Pattern pattern = Pattern.compile("[: ]"); String[] strs = pattern.split(word); for (String s : strs) { System.out.println(s); } }