I am trying to repalce multiple characters (\t, \n or \r) in a given string to only one occurrence of character which is pipeline | :
What is required :
Current string : '\t \r\nFoo\t Fooo\t Dog\t Foo\t \r\n\r\n'
Desired Output : ' |Foo| Fooo| Dog| Foo| '
Here is what i have tried so far :
import re
string = '\t \r\nFoo\t Fooo\t Dog\t Foo\t \r\n\r\n'
re.sub('\r|\n|\t', '|', string)
Here is the output i got '| ||Foo| Fooo| Dog| Foo| ||||' where pipeline is duplicate here.
| |Foo| Fooo| Dog| Foo| |why the first and last disappear ?