Assume `"#"` is like a backspace in string. This means that string `"a#bc#d"` actually is `"bd"`

Your task is to process a string with `"#"` symbols.


## Examples

```
"abc#d##c"      ==>  "ac"
"abc##d######"  ==>  ""
"#######"       ==>  ""
""              ==>  ""
```

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def clean_string(s):
	

Solutions:
def clean_string(s):
	stk = []
	for c in s:
		if c == '#' and stk:
			stk.pop()
		elif c != '#':
			stk.append(c)
	return ''.join(stk)


def clean_string(s):
	result = []
	for c in s:
		if c == '#':
			if result:
				result.pop()
		else:
			result.append(c)
	return ''.join(result)


import re

def clean_string(s):
	while '#' in s:
		s = re.sub('.?#', '', s, count=1)
	return s


def clean_string(s):
	arr = []
	for a in s:
		if a != '#':
			arr.append(a)
		elif arr:
			arr.pop()
	return ''.join(arr)


def clean_string(string):
	out = ''
	for x in string:
		if x != '#':
			out += x
		else:
			out = out[:-1]
	return out


import re

def clean_string(s):
	return clean_string(re.sub('[^#]{1}#', '', s).lstrip('#')) if '#' in s else s


import regex

def clean_string(s):
	return regex.sub('[^#]((?R)*)#+|\\A#+', '', s)


from functools import reduce

def clean_string(s):
	return reduce(lambda x, y: x[:-1] if y == '#' else x + y, s, '')


def clean_string(s):
	ans = ''
	for letter in s:
		if letter == '#':
			if len(ans) > 0:
				ans = ans[:-1]
		else:
			ans += letter
	return ans


clean_string = c = lambda s, o='': c(s[1:], o[:-1] if '#' == s[0] else o + s[0]) if s else o