Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int start = 0;
- boolean startMarked = false;
- char[] chars = input.toCharArray();
- List<String> strings = new ArrayList<>();
- for (int i = 0 ; i < input.length() ; ++i) {
- boolean number = Character.isDigit(chars[i]);
- if (!startMarked && number) {
- startMarked = true;
- start = i;
- } else if (!number && startMarked) {
- strings.add(input.substring(start, i));
- startMarked = false;
- }
- }
- Character[] resultChars = strings.stream().map(str -> (char)Integer.parseInt(str)).collect(Collectors.toList()).toArray(new Character[]{});
- char[] resultArray = new char[resultChars.length];
- for (int i = 0 ; i < resultChars.length ; ++i) {
- resultArray[i] = resultChars[i];
- }
- return new String(resultArray);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement