Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Remove double quotes only if it between character Python

I have a string inside variable a contains double quotation inside double quotations :

Input :

a = ""comment_text": "Siti Sa"diah I need this for my neighbor needs""

Expected result :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

a = ""comment_text": "Siti Sadiah I need this for my neighbor needs""

I tried using

re.sub(r'[^A-Za-z]', '', a)
and I also tried this one:
re.sub('"', '', a)

but it resulting like this :

commenttextSitiSadiahIneedthisformyneighborneeds
and this
comment_text: Siti Sadiah I need this for my neighbor needs

I want to delete double quotation(") only if it between alphabets.

I’m using python for this one. Is anyone could find a way to solve this issue ?

Thanks a lot!

>Solution :

re.sub(r'(\w)"(\w)', r'\1\2', df['comment']) for any word character around "

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading