I've just started studying Python and I got a homework problem where I need to create a dictionary containg words I got from a text file. I managed to read the text from the file, remove specific characters with regex, but I'm having trouble doing the same thing with a specific character combination, like 's
.
I tried using the following code on the variable text
:
text = re.sub("[('s)]", '', text)
The problem with this piece of code is that it removes all the s
characters in the text, even the ones with no leading apostrophe characters.
How could I make sure only s
characters with trailing apostrophes gat removed?