[Question]
  [
In this challenge, your task is to decipher a string. Luckily, the algorithm is pretty simple: reading from left to right, each encountered digit ***N*** (0 to 9) must be replaced with the character which is ***N+1*** positions before it.
### Example
The input string `"Prog2am0in6"` would be decoded this way:
[![example](https://i.stack.imgur.com/JJ2gJ.png)](https://i.stack.imgur.com/JJ2gJ.png)
Hence, the expected output is `"Programming"`.
### Clarifications and rules
* The input string will contain ASCII characters in the range 32 - 126 exclusively. You can assume that it will never be empty.
* The original deciphered string is guaranteed not to contain any digit.
* Once a character has been decoded, it may in turn be referenced by a subsequent digit. For instance, `"alp2c1"` should be decoded as `"alpaca"`.
* References will never wrap around the string: only previous characters can be referenced.
* You can write either a full program or a function, which either prints or outputs the result.
* This is code golf, so the shortest answer in bytes wins.
* Standard loopholes are forbidden.
### Test cases
```
Input : abcd
Output: abcd
Input : a000
Output: aaaa
Input : ban111
Output: banana
Input : Hel0o W2r5d!
Output: Hello World!
Input : this 222a19e52
Output: this is a test
Input : golfin5 3s24o0d4f3r3y3u
Output: golfing is good for you
Input : Prog2am0in6 Puz0les7&1Cod74G4lf
Output: Programming Puzzles & Code Golf
Input : Replicants 4re3lik448ny3oth8r5mac6in8.8T64y'r371it9376a1b5n1fit7or2a1h2z17d.
Output: Replicants are like any other machine. They're either a benefit or a hazard.
```
  
[Answer]
# Java 7, ~~81~~ 80 bytes
```
void a(char[]a){for(int i=0;++i<a.length;)if(a[i]>47&a[i]<58)a[i]=a[i-a[i]+47];}
```
[Try it online!](https://tio.run/nexus/java-openjdk#tY5Na4NAEIbv/oppDmVFKuuqhGAslF56j9BD8DB@L2x2w@7aIsHfbjUpIb3XOcw7X7zPlAKNgQwu05fiFSApO9THHN1LozTh0gJPaeJ5fI@@qGVru8TlDcEjz1@j7fOi@3jnLprO6WUpvGibJ@N07gvBSzAW7SxX@xNySQ5Wc9leGQ78RgYWUpD1N2TETe7j2zNQzLsNFmW18a16n2dvWuPweGh9JMVDfxiMrU@@6q1/nmlWyD/re3FzppSu41ygDIJgHe@PWlAFn0zH1dM6BNtxA4wxDHZ1zNZhtEo0XMYQGhYpWkVNqMMh7P8DNjqjM/0A "Java (OpenJDK 8) – TIO Nexus")
Saved 1 byte thanks to [Anders Tornblad](https://codegolf.stackexchange.com/users/68002/anders-tornblad). The first character cannot be a digit so it doesn't need to be checked meaning we can preincrement before checking our terminate condition.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~9~~ 7 bytes
```
~ịṭṭµ@/
```
[Try it online!](https://tio.run/nexus/jelly#@1/3cHf3w51rgejQVgf9////B6UW5GQmJ@aVFCuYFKUa52Rmm5hY5FUa55dkWBSZ5iYmm2XmWehZhJiZVKoXGZsbZpZYGpubJRommeYZpmWWmOcXGSUaZhhVGZqn6AEA "Jelly – TIO Nexus")
### How it works
```
~ịṭṭµ@/  Main link. Argument: s
    µ    Combine the four links to the left into a chain (arity unknown).
     @   Swap the chains arguments. This makes it dyadic.
      /  Reduce s by the chain with swapped arguments. It will be called with
         right argument r (the result of the previous call, initially the first 
         character) and left argument c (the next character of s).
~            Bitwise NOT of c. This maps a digit 'd' to ~d = -(d+1), but all 
             non-digit characters 'D' to 0.
  ṭ          Tack; append c to r.
 ị           Index; select the character of the result to the right at the
             index from the result to the left. Indexing is 1-based and modular,
             so 0 is the last character, -1 the second to last, etc.
   ṭ         Tack; append the resulting character to r.    
```
[Answer]
## Haskell, 55 bytes
```
o#c|c>'/',c<':'=o!!read[c]:o|1<2=c:o
reverse.foldl(#)[]
```
Usage example: `reverse.foldl(#)[] $ "Prog2am0in6 Puz0les7&1Cod74G4lf"` -> `"Programming Puzzles & Code Golf"`. [Try it online!](https://tio.run/nexus/haskell#BcHBDoIgAADQe1@B2kZtzYagkJO@oFN1cx4IYbIQHFKbzX@39zafyVVe4RmeZANryH2SBCX6Vna1X1FTcFn7neZBfVWYVa697e0hO7bdNgrjAAfTJz5iuDmwBxqkdzVZI4WLMyBBYWvehDC3YB8HFspRyMo4lrNnRRYYMEUmXjCtBHqVDmkTqQ@FQEPxQ7TPU7D9AQ "Haskell – TIO Nexus")
Reduce the string to a reverse copy of itself with the numbers replaced by the corresponding chars. "reverse", because this way we have easy access to the string so far when indexing the numbers. Reverse it again.
[Answer]
# C, 46 bytes
```
f(char*s){for(;*s++;)*s=s[(*s-52)/6?0:47-*s];}
```
[Try it online!](https://tio.run/##XczNToNAFAXgPU9xw8LM0JCLM9OSOCFGW/qTmLYRXBEWhDqVhDJmBhba9NmR6gL1rM7inK/027Lse0XKt8J4lp6VNkR6djKR1LORzYhn/SmjOLsP7kToezaXl75qWjgVVUOoc3ZgyPUNtjVZHrl7o4@sOAVVM4N99xnUrza8uZ3rQyhWolau/H4oMsypfO9a@9P@OOwKHXWtqmYK3DKhg4NQ3PAP3v0G2CiwfwTPcojATdebBBCT9HmzXWGy3r08LXCLuxQeY3hYLuM5IqbxAtAdWT6yQ3Uu/Rc)
---
# C, ~~52~~ ~~49~~ 48 bytes
*Thanks to @l4m2 for saving a byte!*
```
f(char*s){for(;*s++;)*s>47&*s<58?*s=s[47-*s]:0;}
```
Edits the input string directly.
[Try it online!](https://tio.run/##VYyxDoIwFEV3vqJhILSEpEKxxooODq7shIGARRJoTV8ZlPDtCDqodzrDPacKbVXNs/SrW2kI4FFq4wsCQSAwgSPjHoFDsjsRSCFnPCRQ7KmY5lZZ1Jet8rEzOmjZ6iOwJi9SNzO6icqetmqLsuFJuytwb3PWNWcX1klXvA3pL3cs7oOFD/11ojXU6E62KkExREzTmsnYxI94@A1E38KCzjS/AA)
**Alternative 50-byte version:**
```
f(char*s){for(;*s++;)*s=abs(*s-57)>9?*s:s[47-*s];}
```
**Recursive version, 48 bytes:**
```
f(char*s){*s>47&*s<58?*s=s[47-*s]:0;*s++&&f(s);}
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 11 bytes
```
vydiÂyèëy}J
```
[Try it online!](https://tio.run/nexus/05ab1e#@19WmZJ5uKny8IrDqytrvf7/D0otyMlMTswrKVYwKUo1zsnMNjGxyKs0zi/JsCgyzU1MNsvMs9CzCDEzqVQvMjY3zCyxNDY3SzRMMs0zTMssMc8vMko0zDCqMjRP0QMA "05AB1E – TIO Nexus")
**Explanation**
```
v            # for each character y in input
 ydi         # if y is a digit
    Â        #    push a reversed copy of the string we've built up so far
     yè      #    push the character at index y in the reversed string
       ë     # else
        y    #    push y
         }   # end if
          J  # join stack to a single string
             # output top of the stack at the end of the loop
```
[Answer]
# JavaScript (ES6), 59 53 bytes
```
f=x=>/\d/.test(x)?f(x.replace(/\d/,(m,o)=>x[o+~m])):x
```
Saved 7 bytes thanks to fəˈnɛtɪk.
```
f=x=>/\d/.test(x)?f(x.replace(/\d/,(m,o)=>x[o+~m])):x
console.log(f("Prog2am0in6"));
console.log(f("abcd"));
console.log(f("a000"));
console.log(f("ban111"));
console.log(f("Hel0o W2r5d!"));
console.log(f("this 222a19e52"));
console.log(f("golfin5 3s24o0d4f3r3y3u"));
console.log(f("Prog2am0in6 Puz0les7&1Cod74G4lf"));
console.log(f("Replicants 4re3lik448ny3oth8r5mac6in8.8T64y'r371it9376a1b5n1fit7or2a1h2z17d."));
```
[Answer]
## [Retina](https://github.com/m-ender/retina), 37 bytes
Byte count assumes ISO 8859-1 encoding.
```
\d
$*«»
r1+`(?<=(.)(?<-2>.)*)(«)*»
$1
```
[Try it online!](https://tio.run/nexus/retina#Dc49boMwGIDh3adwpagFqiJ//sFEStqhQztGVaQsGWqwCVYcOzLOQK6UI3TjYpTpHZ7lnY8arYrpMf2hCK@/2cdmm5X5kjf6XuZFnk2PvFhwBfOsmlYjRQhBjfIAgL6NIwEfaBT6CaXeDphSqmBtBEWn4DrrBWYD5YFo3rHIRnZDuxhOVF2I9RXe3e7EmUE@w2fQkn9x16Efc3W2VT4NmEfDnD1zXvuRhdTXUVxUW1lfl/W@4uNLZBJsWjNZKWiEh84mGeJy0NM7SP0P "Retina – TIO Nexus")
### Explanation
```
\d
$*«»
```
Replace each digit **d** with **d** `«`s, followed by one `»`. We need the latter a) to be able to recognised positions where **d = 0** and b) as a separator between adjacent digits.
```
r1+`(?<=(.)(?<-2>.)*)(«)*»
$1
```
Repeatedly (`+`) match the regex on the first line from right to left (`r`) and then replace the left-most match (`1`) with the substitution on the second line.
The regex itself matches one of our now unary digits and counts the number of `«`s in group 2. The lookbehind then matches **d** characters with `(?<-2>.)*` before capturing the referred-to character in group 1. The string of `«`s and `»` is then replaced with the captured character.
[Answer]
# [MATL](https://esolangs.org/wiki/MATL), ~~21~~ ~~19~~ ~~17~~ 16 bytes
```
"@t4Y2m?UQ$y]]&h
```
Try it at [**MATL Online!**](https://matl.io/?code=%22%40t4Y2m%3FUQ%24y%5D%5D%26h&inputs=%27Hel0o+W2r5d%21%27&version=19.9.0)
**Explanation**
```
        % Implicitly grab input as a string
"       % For each character in the input
  @     % Push that character to the stack
  t     % Make a copy of it
  4Y2   % Push the pre-defined array '0123456789' to the stack
  m     % Check if the current character is part of this array (a digit)
  ?     % If it is
    UQ  % Convert it to a number and add 1 (N)
    $y  % Make a copy of the element N-deep in the stack. MATL uses one-based indexing
        % So 1$y is the element at the top of the stack, 2$y is the next one down, etc.
  ]     % End of if statement
        % Non-digit characters remain on the stack as-is
]       % End of for loop
&h      % Horizontally concatenate the entire stack to form a string
        % Implicitly display the result
```
[Answer]
## JavaScript (ES6), 51 bytes
```
f=
s=>s.replace(/\d/g,(c,i)=>a[i]=a[i+=~c]||s[i],a=[])
```
```
<input oninput=o.textContent=f(this.value)><pre id=o>
```
`a` is used to store the replaced digits to deal with digits referring to other digits.
[Answer]
# [Perl 5](https://www.perl.org/), 34 bytes
33 bytes of code + `-p` flag.
```
s/\d/substr$_,-$&-1+pos,1/e&&redo
```
[Try it online!](https://tio.run/nexus/perl5#Dc67bsMgFADQna8gauQOjWMuD@PMHdoxiiJ1qVRhg2NUAtYFD87POzlfcN52s8NA63nLza9t8tLngvu/Q72vaviYUz5A46oKnU3bZvrBEsMYI72JAEC@XWCJ/nBUdkfK5DPlnBs4OcXJLYXRR0VF5jIxK0eBYhULOWO6cXNnPrb0vDxYcFlX8Jmsll8yjOTi5uAHE0umEp0I/l/KLq4ilalDdTdD62N37K6tXN9RaPDlJHRroFcRRl90wtdg4g/Q9vgE "Perl 5 – TIO Nexus")
`s/\d/.../e` replace the first digit by `...` evaluated as Perl code. (with `...` being `substr$_,-$&-1+pos,1` in that case. `substr$_,-$&-1+pos,1` returns the substring of `$_` of length `1` at index `-$&-1+pos`, where `$&` is the number just matched, and `pos` is the index of the start of the match. We just need to `redo` if the replace was successful in order to replace every digit. (and the result is implicitly printed thanks to `-p` flag).
---
Old approach, 47 bytes:
44 bytes of code + `-F` flag.
```
map{$F[$i]=$F[$i-$_-1]if/\d/;++$i}@F;print@F
```
[Try it online!](https://tio.run/nexus/perl5#Hc5NS8MwGADge37FO1b0MLrlqx@jDAZC9ThE8KBD0jZtX8ySkmRgJ/72Kp6e67NeTdobSOvloqbvpH5L8Hz4J00@UnbGfvfe7arNJsGfY11NHm081kuVIByAVrAGr4OOaAfonQervyJEHSK0KuhFNW1HFKWUNMoyxsiTNtTBK/dZtyJxxACcc8X2OuNkcKZHm4EIXDrayV54MYsrOXk3cHWhaHM4XW/U6FDcsQfXFfJRmp4868lgq2wMIL0WBj@lLO0sXBxLn11Um6Mtt@VLLud7LwqGcS@KXLEms6zHWDj/Nxj5jRXd9hc "Perl 5 – TIO Nexus")
Quite straight forward actually. `-F` flag splits the inputs on each character into `@F`. `map{...}@F` iterates through `@F` (ie. every character of the input). If the character if a digit (`/\d/`), then we replace it by the character at index `$i-$_-1`. The `$i` is the current index variable (that we maintain by incrementing at each character seen).
[Answer]
# JavaScript ES6, ~~61~~ 59 bytes
Thanks @Luke for golfing off 8 bytes
```
x=>[...x].map((p,i,a)=>a[i]=/\d/.test(p)?a[i-1-p]:p).join``
```
[Try it online!](https://tio.run/nexus/javascript-node#bY09T8MwAER3fkXoALZE3fgjcYqUMjDAWCEkhhKpJrETg2Nbtis1/fOhrCjr3Xt3qp7P9Q6I@oAQOjcQjcID4B80rHfioJt689ltUJIxAQ@frskar33z6CH6dtoej3PrbHRGIuN6oMDqTXqjW2FTzFiQ1Ogfxio7UZeGKhSjaEttK1S9l2y6D5RjnbaUlwJ/FRYrnbgLROCBXDDv0ArCm3/z@@B6IsZc2zLbny65kZHf4WfXcfbCjFowemeUtkVGI2Eu75iigU70tECmQceMkOv/VhZkAXiVJnfZBwlFd/tXz78)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~27~~ 17 bytes
```
vyDdiU)DRXèU`X}}J
```
[Try it online!](https://tio.run/nexus/05ab1e#@19W6ZKSGarpEhRxeEVoQkRtrdf//0GpBTmZyYl5JcUKJkWpxjmZ2SYmFnmVxvklGRZFprmJyWaZeRZ6FiFmJpXqRcbmhpkllsbmZomGSaZ5hmmZJeb5RUaJhhlGVYbmKXoA "05AB1E – TIO Nexus")
```
vy             }  # For each character
  Dd              #   Push is_number
    i         }   #   If it is
     U            #     Save save it
      )DR         #     Wrap the (reversed) stack into an array
         Xè       #     Get the character at the saved index
           U`X    #     Flatten the whole stack
                J # Join 
```
[Answer]
# CJam, 13 bytes
```
q{_A,s#)$\;}/
```
[Online demo.](http://cjam.aditsu.net/#code=q%7B_A%2Cs%23)%24%5C%3B%7D%2F%0A&input=Prog2am0in6)
This solution uses CJam's built-in "copy *n*-th item on the stack" operator `$` to implement the decoding.
It starts by reading the input (with `q`) and then looping over the characters from the input string and dumping them onto the stack (with `{}/`).
However, inside the loop body it also duplicates each character after it has been put on the stack (with `_`) and checks if it's a digit by looking up its position with `#` in the string `"0123456789"`, conveniently represented as `A,s`.
The result of this lookup is either the digit's numeric value or, if the character is not a digit, -1. The `)` operator then increments that value by one, and `$` replaces it with the character current at that many positions below the top of the stack. Finally, `\;` just removes the copy of the current input character that we made with `_` from the stack, as it's no longer needed.
[Answer]
# [Befunge-98](https://github.com/catseye/FBBI), ~~45~~ 43 bytes
```
::::#@~\1p:1g::'9`!\'/`*j;'/--1g\1p\1g#;,1+
```
[Try it online!](https://tio.run/nexus/befunge-98#@28FBMoOdTGGBVaG6VZW6pYJijHq@glaWdbq@rq6hulAiRjDdGVrHUPt//8TcwqMkg0B "Befunge-98 – TIO Nexus")
The idea:
1. For each char in the input string,
	1. Write it to line 2
	2. If it is not a number, just output it
	3. Otherwise, look up the correct value, rewrite it, then output it
```
::::            ; There's a counter on the stack, duplicate it 4 times  ;
    #@~         ; Get the next char of input, exiting if there is none  ;
       \1p      ; At the location (counter, 1), write the input char    ;
          :1g   ; Re-obtain the char. Stack is now [counter * 4, input] ;
::                ; Stack: [counter * 4, input * 3]      ;
  '9`!\'/`*       ; If !(input > '9') and (input > '/')  ;
                  ; IE If ('0' <= input && input <= '9') ;
           j;...; ; Then execute the ...                 ;
; Stack: [counter * 4, input] ;
; The ... branch:             ;
'/-             ; input -> int. (input -= '/')             ;
   -            ; counter - int(input) - 1                 ;
                ; Stack: [counter * 3, lookupPosition ]    ;
    1g          ; Get the char that we want to find        ;
      \1p\1g#   ; Overwrite the current char (not the old) ;
; Both branches: ;
,1+             ; Print the number and increment the counter ;
```
---
I wasn't able to get this version shorter, but this one is 44 bytes:
```
s #@~\3p:3g::'9`!\'/`*j;'/--3g#;:10g3p,1+:::
```
Thought I'd share it because of the neat trick with `s` - but storing the counter on the stack leads to that 1 char improvement
[Answer]
# [Python 2](https://docs.python.org/2/), 59 bytes
```
s=''
for c in input():s+=c['/'<c<':':]or s[~int(c)]
print s
```
[Try it online!](https://tio.run/nexus/python2#DcmxDoMgFEDR3a8gLk/TpA2CQIn@RNPNOFCq8aUWCNDBDv11a3KHk9w99QDF7COxBN1R@OSq1unU2wEu0NkONOjx@Gn4ocuVrccixEMk7Xt5m8KK1ricCI8TW/HFuXIb83lRsX0bK9Cps7oLvkFkkmK@MikMfbSOzpilj42hS/Ol8ln@AQ "Python 2 – TIO Nexus")
[Answer]
# Python 2, ~~75~~ 71 bytes
```
s='';j=-1
for i in input():s+=s[j-int(i)]if'/'<i<':'else i;j+=1
print s
```
[Try it Online!](https://tio.run/nexus/python2#@19sq65unWWra8iVll@kkKmQmQdEBaUlGppWxdq2xdFZupl5JRqZmrGZaer66jaZNupW6qk5xakKmdZZ2raGXAVFQHmF4v//1QOK8tONEnMNMvPMFAJKqwxyUovN1Qyd81PMTdxNctLUAQ)
**Edit:** Fixed for ascii values between 32-47 **;** Fixed for double decoding (eg. "alp2c1" to "alpaca")
[Answer]
# PHP 7.1 ~~67~~ 59 bytes
```
while(_&$c=$argn[$i++])$t.=($c^"0")<"
"?$t[~+$c]:$c;echo$t;
```
Takes input from STDIN; run as pipe with `-nR` or [try it online](http://sandbox.onlinephpfunctions.com/code/e551b53d933d0cdd0a872a88eaac5d66862dbc2e).
* `_&$c=$s[$i++]` loop through string (`_&$c` will result in something that is not `"0"`; so the only character that can break the loop is the empty string = end of input)
* `$c^"0"` toggle bits 5 and 6 in the ascii code
* `<"\n"` check if result is < chr(10)
* if so, it is a digit: print previous character by index (and copy to current index)
* else print this character
Thanks @Christoph for saving 12%
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), ~~25~~ 23 bytes
-2 bytes thanks to @FrownyFrog
```
((⊂⌷⊢)⍣≡⍳∘≢-11|⎕d∘⍳)⊃¨⊂
```
[Try it online!](https://tio.run/##hcwxTwIxFMDxnU9RFx4MJG3vkOjqgCObc6HX82Lhmd4xgLqoMYKecTFxFRd3Ykwc/Sjvi5wPGFxQ2@bS9n7/mlPfshPjMW0NvMnzbFDRw1OGdPOoKsffRoPml3T/QfNFk8pXmr1QuaTbZ5otWkqdM7arU7ls0vzq641xVRXcnVH5zjjw1lH5uQ94AnR3Dc5kHviCf4eLGpj@wIL4fRQbwVBK@Q/kwbBvRkop@AOy4Mn0MPESxZEObbsDWykLzwKDZ1GD4jjLhdbaqL2krWFLsBa8jCiSvOAkRe@yUVtEuY5R2thFIZpEY/hJNiJdVSmiFQ6DmOCY217AVJuhzEa7ojeeSp/knbo6QNuJu7F3UKxFMMPhqmcxZSHqgkUiuvwsfAM "APL (Dyalog Classic) – Try It Online")
uses `⎕io←1`
(`⍵` below stands for an intermediate value in the evaluation)
`⎕d` is the string `'0123456789'`
`⎕d⍳⍵` finds the (1-based in this case) indices of `⍵`'s chars in `⎕d`; for a non-digit the index is 11
`11|⍵` is modulo - the 11s become 0s
`≢⍵` is the length of `⍵`
`⍳≢⍵` is `1 2 ...` till `≢⍵`
so, `(⍳≢⍵)-11|⎕d⍳⍵` gives us a vector *i* of the indices where we should look to get the resulting characters; however some of those indices may redirect to yet other (smaller) indices. To compute the transitive closure (i.e. the effective indices), we index the vector into itself (`⊂⌷⊢`, a train equivalent to `(⊂i)⌷i` or `i[i]`) and repeat that until it stabilises (`⍣≡` is known as the *fixed point* operator).
finally we index into the original string: `(...)⊃¨⊂`
[Answer]
# Vim macro/keystrokes, ~~49~~ 29 bytes
`^M` represent the return character (0x0A, 1 byte).
```
qaqqa/\d^Myl@=@"+1^Mhylnvp@aq@a
```
## Explanation
```
qaq                                 clear register a
   qa                               record into a
     /\d^M                          move the cursor to the next digit
          yl                        yank the digit
            @=@"+1^Mh               move the cursor left that number of characters plus one
                     yl             yank the char
                       n            go back to the digit
                        vp          replace the digit with the yanked char
                          @a        recursive call will execute until the search for a digit fails
                            q       stop recording
                             @a     run the macro
```
[Answer]
# [Python 2](https://docs.python.org/2/),~~83~~ 80 bytes
```
r=input()
for i in r:
 if'/'<i<':':r=r.replace(i,r[r.find(i)+~int(i)],1)
print r
```
[Try it online!](https://tio.run/nexus/python2#DcexDoIwFAXQvV/xJl8bCYIhkjQwObiyGwcirXlJbZsrLA7@emU6OQWjxLyt2iifQEISCVaReD7xIANbthhRw@UwP52WCnfUXuKixRx/EtfdR9UalbGHUApPSK/z/G4kXmjavk1wn/7QXtPSd7cueP4D "Python 2 – TIO Nexus")
* saved 3 bytes but checking ascii instead of is digit! Thanks to math\_junkie!
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 24 bytes
```
£Xn >J?U=UhYUgJ+Y-X):PÃU
```
[Try it online!](https://tio.run/nexus/japt#@39ocUSegp2XfahtaEZkaLqXdqRuhKZVwOHm0P//lYJSC3IykxPzSooVTIpSjXMys01MLPIqjfNLMiyKTHMTk80y8yz0LELMTCrVi4zNDTNLLI3NzRINk0zzDNMyS8zzi4wSDTOMqgzNU/SUAA)
### Explanation:
```
£Xn >J?U=UhYUgJ+Y-X):PÃU
£                     Ã    Iterate through the input (implicit U) 
                             X becomes the iterative item, Y becomes the index
 Xn                          Try parseInt(X)
    >J                       > -1
                               In this case, this checks if X is a digit
      ?                      If true:
       U=                      Set U to 
         UhY                     U with the char at index Y set to:     
            UgJ+Y-X               The index at -1+Y-X
                   ):        Else:
                     P         variable P (just a no-op in this case)
                       U   Finally, return U
        
```
[Answer]
# Ruby, ~~56~~ 46 bytes
```
->s{i=0;s[i]=s[i+~s[i].to_i]while i=s=~/\d/;s}
```
[Try it online!](https://repl.it/HAmP/2)
[Answer]
# [Python 2](https://docs.python.org/2/), 58 bytes
```
lambda s:reduce(lambda t,c:t+(c+t)['/'<c<':'and~int(c)],s)
```
This is essentially a port of my Jelly answer, plus the digit check from @xnor's Python answer.
[Try it online!](https://tio.run/nexus/python2#LcfBDoIgGADgV2FegNlsCAo5e4nWrTrgD06WosO/gx16devQd/t6cib3fbRT5yxZm@TdCzz7Hw/QYM4gR36jR9pCSxtqo/uEiAz447DyfUm/kJ5lF7@MAWzElajk5RieSpm4yRkHk6rJQh2iKcy1VhtNUouAJ6lrK7oqij6gnlNpxVC@hXZFxvcv "Python 2 – TIO Nexus")
[Answer]
# [Röda](https://github.com/fergusq/roda), 51 bytes
```
f a{x=0;a|{|y|a[x]=a[x+47-ord(y)]if[y=~`\d`];x++}_}
```
[Try it online!](https://tio.run/nexus/roda#HY69bsIwGEXn@ClcBgqKivyXOBRl6tCOqKrUgUblSxwTq4mNHCMRAn11GnW5uvec5d41hvGckw1cx@twhd25yKeIhXxyXi2GZWH0bsh/919qX2zOcXz7vt07MBaPKNLOY2OPp4CVQ1HUB4@fc7yrGvD94l8si4nrxWSWUzl6YwOexnw2Q5Fytka3O5SVQkAIQSVYSil6q1vi8CfziXpAoTE9ZowBXdcJQwfXamMTzHsmHFFCc88HfkJb7w4MOmJsirenC2nrXs7pi1NSvIpWo/f62JoKbOix8DVvzY8QmR24C03mkw6q1NhslX2kYnj0XFIT1lymQMvEUm2CdH560LALlWr1Bw "Röda – TIO Nexus")
[Answer]
# JavaScript ES6, 54 bytes
```
f=r=>[...r].reduce((a,s,i)=>a+(/\d/.test(s)?a[i+~s]:s))
```
```
f=r=>[...r].reduce((a,s,i)=>a+(/\d/.test(s)?a[i+~s]:s))
console.log(f("Prog2am0in6"));
console.log(f("abcd"));
console.log(f("a000"));
console.log(f("ban111"));
console.log(f("Hel0o W2r5d!"));
console.log(f("this 222a19e52"));
console.log(f("golfin5 3s24o0d4f3r3y3u"));
console.log(f("Prog2am0in6 Puz0les7&1Cod74G4lf"));
console.log(f("Replicants 4re3lik448ny3oth8r5mac6in8.8T64y'r371it9376a1b5n1fit7or2a1h2z17d."));
```
[Answer]
# ><> (Fish), 108 bytes (= 9 x 12 grid)
```
01-r>:0(\
"/"&::;?/
)?\v    \
":/v!?(":
")\ :>:"0
 !?\
${/  \ -1
&>\ ~{:&$
\ \ :"0"=
/\- 1}$/?
:v&//}~/~
 \o}\&$/ 
```
Try it [here](https://fishlanguage.com/playground) to see the fish swimming around.
* Append -1 to the input stack then reverse the stack.
* Loop: If top value is -1 then end (we've cycled through all characters). Otherwise:
* Put the top character in the register; check to see whether it's in the range "0" to "9". If so:
	+ rotate the stack the appropriate number of places
	+ get the character being pointed to
	+ rotate back and replace the number with the character from the register
* Output; resume loop.
[Answer]
# 8086 machine code, 35 bytes
```
00000000  be 82 00 ac 98 50 2c 30  3c 09 77 0c 4e 89 f7 4e  |.....P,0<.w.N..N|
00000010  29 c6 58 ac aa 89 fe 50  5a b4 02 cd 21 80 fa 0d  |).X....PZ...!...|
00000020  75 e1 c3                                          |u..|
00000023
```
[Answer]
# oK, 39 bytes
```
{x{x[y 0]:x@-/y}/(!#x),'0|{x*11>x}x-47}
```
[Try it online!](https://tio.run/nexus/k-ok#DY49T8MwGIT/ihsk2iLa@PVHnAYJVWKAsUJIDIjBiePGwrWRk0pOQ3578HR3z91wi66mOMWvEeHvKh53@Tjnm9Vd3D6u8d8UHwCe4xx3TMyLPubVJpN1o7KnTGKMk9TSAUAyb63FHn2SwNUqxaEzPSKESDi0nCRw9lYbxxHtCfNYMU0DHek1Nafgz0ResHEFOl1v2La9uIcXrwR7ZVanxXv7a00j3dAjFlpqzQ9jpRupH7oy8ItsCuPKfflRsHEdqAAzHKgoJNTcgTaD8CH96MgNhNpn2@Uf)
[Answer]
# [Japt](https://ethproductions.github.io/japt/) v2.0a0, 16 bytes
```
r\d@=hYUgY-°X¹gY
```
[Try it](https://ethproductions.github.io/japt/?v=2.0a0&code=clxkQD1oWVVnWS2wWLlnWQ==&input=IlJlcGxpY2FudHMgNHJlM2xpazQ0OG55M290aDhyNW1hYzZpbjguOFQ2NHkncjM3MWl0OTM3NmExYjVuMWZpdDdvcjJhMWgyejE3ZC4i)
---
## Explanation
```
                     :Implicit input of string U
r                    :Replace
 \d                  :  RegEx /\d/g
   @                 :  Pass each match X at index Y through a function
     hY              :    Set the character at index Y in U
       UgY-°X        :    To the character at index Y-++X
    =        ¹       :    Reassign to U
              gY     :    Get the character at index Y
```
[Answer]
# [J](http://jsoftware.com/), 20 bytes
```
{~[:{~^:_#\-2+_1".,.
```
[Try it online](https://tio.run/##Dc7LSgMxFADQfb4iKtSFNeTmMZkWdCOoCxdFCi6UlkwenWiaSCazmBb666PnC873PPsHgs@Xz/X5slvvb77u2d0ersmSzM70GfvFIzZjfXvGQ7UhYZh1ZyzSlFLU6QQA6NVFmvEHK9JeodqHATPGNKycZOiQow9JYj4wkakVnhc@8RFtSj4wfaQhNXgznmh0g1rAU7ZKvIjo0bv7jcHoVAcsiuMx/AjRponn2rdFHrVpQmpJu23EdFu4glBXXDUaOpnAh6py@R/07ATKkj8)
```
                  ,.  Each character on a separate row
              _1".    Convert to numbers, replacing non-numbers with -1
                         (it becomes one row again)
            2+        Add 2.
         #\           Prefix lengths (range 1..length)
           -          Subtract
  [:{~^:_             Index into itself as long as it changes the result
{~                    Index into the original string
```
[Credit to ngn for the inspiration.](https://codegolf.stackexchange.com/a/115924/74681)
### 22 bytes
```
(],,{~1{._1-_1".[)/@|.
```
This is a port of the Jelly answer.
```
                    |. The string backwards, because reduce is right-to-left.
            _1".[      The next character as a number (d), -1 if it's not a number,
                          and a space character produces an empty array.
         _1-           -1-d
      1{.              Take 1. If we have a nothing
                          at this point, that makes it a 0.
   ,                   Prepend the next character to the result of the previous call.
    {~                 Select the character. 0 is the first, _2 is second to last.
 ],                    Append the result.
```
In both solutions the version that TIO uses interprets a single `.` as the number 0, so the last test fails. Older versions (≤7) seem to work correctly.
[Try it online!](https://tio.run/##Dc7LSgMxFADQfb4idlEVaszNYzJdKIKgLlyUIriQUjJ5dKJpIpnMYlrx10fPF5zPefZ3BF/tVqvzL5zJHm72sCAf17cPP2R2ps/YL@@xGevrEx6qDQnDrDtjkaaUok4nAEAvLtKM31mR9gLVPgyYMaZh7SRDhxx9SBLzgYlMrfC88ImPaFPygekjDanBm/FEoxvUEh6zVeJZRI@27jsGo1MdsCiOx/AlRJsmnmvfFnnUpgmpJe1bI6bLwhWEuuaq0dDJBD5Ulcv/oGcnUJb8AQ "J – Try It Online")
]