RLE Brainfuck dialect RLE Brainfuck

(related to BF-RLE)

The hypothetical RLE (Run-Length Encoding) dialect of Brainfuck accepts the symbols for the 8 commands and also accepts digits. The digits are used to represent the number of successive repetitions of a command, thus allowing run-length encoding of the source code.

8&gt; is equal to &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;.

The length is always on the left side of the command.

Your task is to write the shortest program/function that translates the input string (RLE Brainfuck fragment) into a regular Brainfuck program.

For example:

Input:

10+[&gt;+&gt;3+&gt;7+&gt;10+4&lt;-]3&gt;2+.&gt;+.7+2.3+.2&lt;2+.&gt;15+.&gt;.3+.6-.8-.2&lt;+.&lt;.


Ouptut:

++++++++++[&gt;+&gt;+++&gt;+++++++&gt;++++++++++&lt;&lt;&lt;&lt;-]&gt;&gt;&gt;++.&gt;+.+++++++..+++.&lt;&lt;++.&gt;+++++++++++++++.&gt;.+++.------.--------.&lt;&lt;+.&lt;.


The shortest code in byte count in each language will win.
Python 2, 62 61 bytes



lambda s:eval(re.sub('(\d*)(.)',r'+1*\1*1*"\2"',s))
import re


Try it online!

The regex substitution expands 3&lt;2+- into the string:

+1*3*1*"&lt;"+1*2*1*"+"+1**1*"-"


which is then evaled. (Note how when \1 is empty, we get 1**1 = 1.) The first + is a unary operator which binds to the first number, and the other +s are string concatenation. This beats the more obvious

lambda s:re.sub('(\d+)(.)',lambda m:int(m.group(1))*m.group(2),s)
import re


by 14 bytes. Ordinarily "\2" wouldn’t always work, but thankfully \ and " aren’t brainfuck commands.



xnor saved a byte, supplying the 1*\1*1 trick. Previously I had \1L in the regex, and defined L=1 as a lambda argument, which is also pretty cool: 3L is a long int literal and L is a variable.