java - How do I parse multiple integers from a string -
i have following string: "b:0123eh:0234et:0444"
, need parse integers "0123; 0234; 0444"
separate integers.
regex might useful:
string numbersstr[] = "b:0123eh:0234et:0444".split("[a-z]+:0"); int numbers[] = new int[numbersstr.length - 1]; (int = 1; < numbersstr.length; i++) { numbers[i - 1] = integer.parseint(numbersstr[i]); system.out.println(numbers[i - 1]); }
now have array of integers. , @cricket_007 's comment. can replace pattern [^0-9]+
.
ps; work if pattern mentioned above recurring
Comments
Post a Comment