I tried:
re.sub(r'[^crfl](?=(\.|\,|\s|\Z))', '', val, flags=re.I)
on string
car. cupid, fof bob lol. koc coc, cob
but the result is:
car cupi fof bo lol koc coc co
I don't uderstand, why lookahead assertion deleted commas and dots.
The result I'm for is:
car. cupi, fof bo lol. koc coc, co
[^crfl.,](?=(\.|\,|\s|\Z))
just include .,
in negation list
.See demo.
https://regex101.com/r/yX8zV8/5
or simply
\w(?<![crlf])\b
See demo.
https://regex101.com/r/eB8xU8/1
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