I would like to remove any single letter from a string in python.
For example:
input: 'z 23rwqw a 34qf34 h 343fsdfd'
output: '23rwqw 34qf34 343fsdfd'
Been trying to figure out for a while with regex without success. I know how to cut things from certain char/symbol in two pieces, but not what I am trying to do.
I have been tinkering with
re.sub(r'^[^ ]*', '', text)
Using 'str. replace() , we can replace a specific character. If we want to remove that specific character, replace that character with an empty string. The str. replace() method will replace all occurrences of the specific character mentioned.
Use the . strip() method to remove whitespace and characters from the beginning and the end of a string. Use the . lstrip() method to remove whitespace and characters only from the beginning of a string.
>>> ' '.join( [w for w in input.split() if len(w)>1] )
'23rwqw 34qf34 343fsdfd'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With