Given a string that includes alphanumeric characters ('3a4B2d') return the expansion of that string: The numeric values represent the occurrence of each letter preceding that numeric value. There should be no numeric characters in the final string. Empty strings should return an empty string. 
 
The first occurrence of a numeric value should be the number of times each character behind it is repeated, until the next numeric value appears.
```python
string_expansion('3D2a5d2f') == 'DDDaadddddff'
```
```python
string_expansion('3abc') == 'aaabbbccc'       # correct
string_expansion('3abc') != 'aaabc'           # wrong
string_expansion('3abc') != 'abcabcabc'       # wrong
```
If there are two consecutive numeric characters the first one is ignored.

```python
string_expansion('3d332f2a') == 'dddffaa'
```
If there are two consecutive alphabetic characters then the first character has no effect on the one after it.

```python
string_expansion('abcde') == 'abcde'
```
Your code should be able to work for both lower and capital case letters.

```python
string_expansion('') == ''
```

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def string_expansion(s):
	

Solutions:
def string_expansion(s):
	(m, n) = ('', 1)
	for j in s:
		if j.isdigit():
			n = int(j)
		else:
			m += j * n
	return m


import re

def string_expansion(s):
	return ''.join((''.join((int(n or '1') * c for c in cc)) for (n, cc) in re.findall('(\\d?)(\\D+)', s)))


def string_expansion(s):

	def f():
		repeat = 1
		for c in s:
			if c.isdigit():
				repeat = int(c)
			else:
				yield (c * repeat)
	return ''.join(f())


import re

def string_expansion(s):
	return re.sub('(\\d)+([a-zA-Z]*)', lambda m: ''.join((ch * int(m.group(1)) for ch in m.group(2))), s)


import re

def string_expansion(s):
	return re.sub('\\d*?(\\d?)(\\D*)', lambda m: ''.join((int(m.group(1) or 1) * c for c in m.group(2))), s)


def string_expansion(s):
	strin = []
	multiplier = 1
	result = ''
	for letter in s:
		try:
			strin.append(int(letter))
		except ValueError:
			strin.append(letter)
	for i in strin:
		if isinstance(i, int):
			multiplier = i
		elif isinstance(i, str):
			result += multiplier * i
	return result


import re

def string_expansion(s):
	out = []
	for (n, chars) in re.findall('([0-9]?)([a-z]+)', s, re.I):
		out.append(''.join((x * int(n or 1) for x in chars)))
	return ''.join(out)


import re

def string_expansion(stg):
	result = ''
	for match in re.finditer('\\d*(^|\\d)([^\\d]+)', stg):
		count = int(match.group(1) or 1)
		for char in match.group(2):
			result = f'{result}{count * char}'
	return result


def string_expansion(s):
	dec = 1
	ret = ''
	for e in s:
		dec = {0: dec, 1: e}[e.isdigit()]
		ret += ['', e * int(dec)][e.isalpha()]
	return ret


def string_expansion(s):
	from re import findall
	result = findall('^[a-zA-Z]*', s)[0]
	for i in findall('(\\d)([a-zA-Z]+)', s):
		for j in i[1]:
			result += j * int(i[0])
	return result