Apostrophe removal | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Apostrophe removal

I want to remove apostrophes in all verbs and change it to normal format in python. What is the best way whether regex pattern or any packages to do it? For eg. didn't > did not, I'm > I am

25th Jan 2019, 7:05 AM
Bishu Giri
Bishu Giri - avatar
4 Answers
25th Jan 2019, 7:39 AM
Burey - avatar
+ 6
This is actually a lot more complicated than it looks like because you have to consider that people use all kinds of different apostrophes (', ', `), lower and capital letters etc. Probably regex would be the most efficient method. However, here's a code that does everything manually (and still isn't case sensitive): https://code.sololearn.com/cFv7sq6t9ba2/?ref=app /Edit: "ain't" can also be "isn't" , right? 🤔
25th Jan 2019, 12:56 PM
Anna - avatar
+ 3
That's a tricky problem because: didn't => did not -> dn' => {d no} I'm => I am ->' => { a} So I think a case-by-case basis is better.
25th Jan 2019, 7:22 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
I think you want to do something like this: https://code.sololearn.com/cEtLpX01MlA3/?ref=app
25th Jan 2019, 8:00 AM
Sahil Danayak
Sahil Danayak - avatar