0

I have a string:

"Yes, We do. This is a complex issue that deserves more than a one word answer," Zuckerberg said. Pallone called the response "disappointing."

What is the best way to remove dot mark (.) if it in between the quotation marks using Python? the expected result is like:

"Yes, We do This is a complex issue that deserves more than a one word answer," Zuckerberg said. Pallone called the response "disappointing"

Thank you

1 Answer 1

1

You can capture all quotes "..." with regex (\"[\s\S]*?\") and handle the replace in a loop. First replace the . and store into newquote. Then replace the old quote with the new one.

import re;

s = '"Yes, We do. This is a complex issue that deserves more than a one word answer," Zuckerberg said. Pallone called the response "disappointing."';

pattern = re.compile(r'(\"[\s\S]*?\")');

for (quote) in re.findall(pattern, s):
    newquote = quote.replace('.', '');
    s = s.replace(quote, newquote);

print s;
Sign up to request clarification or add additional context in comments.

1 Comment

Sure. Thanks. Have a great day!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.