What is the most efficient way to strip all spaces and quotes from a string with python?

python, regex, string

Solution

Use `strip` with a string containing the characters you wish to strip from the ends:

s = s.strip(' "\'\t\r\n')

Problem

Possible Duplicate: Best way to strip punctuation from a string in Python I have a string I want to put between 2 double quotes on output `"{{ var }}"`, so I want to make sure all single/double quotes are removed from the ends of the user-supplied string. What is the most efficient way to accomplish this? Inputs / desired outputs: ``` """""""""" string here ''''''''''''''' => 'string here' string'''''''""""""''''''""""" => 'string' ```

Original source

Related problems