Guest User

Untitled

a guest
Apr 13th, 2016
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. static String unpack(String source) {
  2.     Matcher m = Pattern.compile("(\\w)(\\d)*").matcher(source);
  3.     return Stream
  4.             .generate(() -> m.find() ? Pair.of(m.group(1), m.group(2)) : null)
  5.             .takeWhile(s -> s != null)
  6.             .flatMap(s -> IntStream.range(1, ("".equals(s.snd) ? 1 : Integer.parseInt(s.snd))).mapToObj(a -> s.fst))
  7.             .collect(Collectors.joining());
  8. }
Advertisement
Add Comment
Please, Sign In to add comment