## Python 3 (<s>164</s> <s>194</s> <s>186</s> 181 bytes) ## p=0 x=input().split() w=x[0] for i in x[1:]: if i[0]=='+':w,p=w[:p]+i[1:]+w[p:],0 else: try:p=w[p:].index(i[1:])+p except:p=len(w) w=w[:p]+w[p:].replace(i[1:],'',1) print(w) Example demonstrating the pointer moving to the end if it doesn't find a substring: Input: HelloThere -x +Friend Output: HelloThereFriend Old answer: p=0 x=input().split() w=x[0] for i in x[1:]: if i[0]=='+': w=w[:p]+i[1:]+w[p:] p=0 else: p=w[p:].index(i[1:])+p w=w[:p]+w[p:].replace(i[1:],'',1) print(w) Example demonstrating the pointer works (all the examples in the Q work even if you don't factor in the pointer and simply replace on first occurence): Input: HelloThereCowboy -r -e -y +ySays +Oh Output: OhHelloTheCowboySays Edit: Since 2 minutes ago my answer is now invalid according to a comment by the asker. > aaa -b +b would result with aaab because the pointer would go all the > way to the end. Edit2: Fixed.