<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def slugify(string, repchar='_'):
 """replaces all non-alphanumeric chars in the string with the given repchar. :param string: the source string :param repchar: """

    slug_regex = re.compile(r'(^[{0}._-]+|[^a-z-A-Z0-9_.-]+|[{0}._-]+$)'.format(repchar))
    strip_regex = re.compile(r'[{0}._-]+'.format(repchar))

    transformations = [
        lambda x: slug_regex.sub(repchar, x),
        lambda x: strip_regex.sub(repchar, x),
        lambda x: x.strip(repchar),
        lambda x: x.lower(),
    ]
    result = string
    for process in transformations:
        result = process(result)

    return result