How to Remove Quotes from Strings in Python

share link

by vigneshchennai74 dot icon Updated: Feb 16, 2023

technology logo
technology logo

Guide Kit Guide Kit  

There will be some situations where we need to remove some particular words in a string. To remove specific words from a string in Python, you have several options. In that, we have used re-module in python.

The re-module in Python provides support for regular expressions. Regular expressions are a powerful tool for matching patterns in text and can be used for various tasks such as searching, parsing, and manipulating strings. Using regular expressions: The re-module in Python provides functionality for working with regular expressions. To remove specific words from a string, you can use the re. sub() method. The r"\b{}\b".format('[\s\-]*'.join(x)) is a string formatting expression that generates a regular expression pattern. It is used to match a specific word, surrounded by word boundaries (\b), in a string.

Some of the common functions in the re module are:

  •, string): Searches for the first occurrence of a pattern in a string and returns a match object if found, or None if no match is found.
  • re.findall(pattern, string): Returns a list of all non-overlapping matches of a pattern in a string as strings.
  • re.sub(pattern, repl, string): Replaces all occurrences of a pattern in a string with a replacement string.
  • re.split(pattern, string): Splits a string by a pattern and returns a list of the parts.
  • re.compile(pattern): Compiles a regular expression pattern into a regular expression object, which can be used for multiple searches and replacements.

In both cases, you can modify the code to handle multiple words to remove, different replacements, or more complex word matching.

Here are examples of removing words in the double quotation.

Preview of the output that you will get on running this code from your IDE


In this solution, we have used re module in python.

  1. Copy the code using the "Copy" button above, and paste it in a Python file in your IDE.
  2. Enter the Text
  3. Run the code to get the Output

I hope you found this useful. I have added the link to dependent libraries, version information in the following sections.

I found this code snippet by searching for "Remove the words with Double Quotation and Space in Python" in kandi. You can try any such use case!

Environment Tested

I tested this solution in the following versions. Be mindful of changes when working with other versions.

  • The solution is created in Python 3.7.15 Version

Using this solution, we can collect the sentence that the user needs with the help of a function in spaCy. This process also facilities an easy-to-use, hassle-free method to create a hands-on working version of code which would help us extract the sentence in python.


  1. For any support on kandi solution kits, please use the chat
  2. For further learning resources, visit the Open Weaver Community learning page