title: Python: strip function definition using regex
body: <p>I am a very beginner of programming and reading the book "Automate the boring stuff with Python'. In Chapter 7, there is a project practice: the regex version of strip(). My code below does not work (I use Python 3.6.1). Could anyone help?</p>
  
  <pre><code>import re
  
  string = input("Enter a string to strip: ")
  strip_chars = input("Enter the characters you want to be stripped: ")
  
  def strip_fn(string, strip_chars):
      if strip_chars == '':
          blank_start_end_regex = re.compile(r'^(\s)+|(\s)+$')
          stripped_string = blank_start_end_regex.sub('', string)
          print(stripped_string)
      else:
          strip_chars_start_end_regex = re.compile(r'^(strip_chars)*|(strip_chars)*$')
          stripped_string = strip_chars_start_end_regex.sub('', string)
          print(stripped_string)
  </code></pre>