This one is slightly slower, it takes about 4.1e-06s to execute. With both codes I noticed it block when encountering a special char:
input: "it BS|BS||BS||BS||BS||BS|this is one|BS||BS|an example"
outpt: "this is an example"
input: "it BS|BS||BS||BS||BS||BS|this is on.e|BS||BS||BS|an example"
outpt: "this is on.an example"
Actually, I timed the original code, and I am quite amazed to realize it is the fastest with an average of 1.7e-06s.. !
input: "it BS|BS||BS||BS||BS||BS|this is one|BS||BS|an example"
outpt: "this is an example"
input: "it BS|BS||BS||BS||BS||BS|this is on.e|BS||BS||BS|an example"
outpt: "this is on.an example"
Actually, I timed the original code, and I am quite amazed to realize it is the fastest with an average of 1.7e-06s.. !