Skip to main content
1 of 4
nwellnhof
  • 10.6k
  • 1
  • 19
  • 38

Perl 6, 57 bytes

{S[\.<((\d)*]=[~] $0[^reduce {$^a>($^b&++$)??$b!!$a},$0]}

Try it online!

Explanation

{
 S[          # replace regex match
   \.        #   literal dot
   <(        #   start match
   (\d)*     #   sequence of digits, stored in $0
 ]=          # with
 [~]         #   concatenation of
 $0[^        #   digits up to
   reduce {          # reduce digits
     $^a>($^b&++$)   # if digit and index less than acc
     ??$b            # then digit
     !!$a            # else accumulator
   },$0
 ]
}
nwellnhof
  • 10.6k
  • 1
  • 19
  • 38