Is there a simple way to parse the following String to List of Integers:
String s = \"1,2,5-9,11,12\" // expected values list: [1,2,5,6,7,8,9,11,12] List
List out=new ArrayList(); String numbers[]=s.split(","); for(String part:numbers){ if(part.contains("-"){ int a=Integer.parseInt(part.split("-")[0]); int b=Integer.parseInt(part.split("-")[1]); while(a<=b){ out.add(a++); } }else{ out.add(Integer.parseInt(part)); } }