import re


def _strip(string):
    """Remove non-word characters from either end of the string.

    Like `str.strip` but also removing punctuation.
    """
    string = re.sub(r'^\W*', '', string)
    string = re.sub(r'\W*$', '', string)
    return string