<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def assert_regex(text, regex, msg_fmt="{msg}"):
 """Fail if text does not match the regular expression. regex can be either a regular expression string or a compiled regular expression object. Traceback (most recent call last):
 AssertionError: 'Hello World!' does not match '\\\\d' The following msg_fmt arguments are supported: * msg - the default error message * text - text that is matched * pattern - regular expression pattern as string """


    compiled = re.compile(regex)
    if not compiled.search(text):
        msg = "{!r} does not match {!r}".format(text, compiled.pattern)
        fail(msg_fmt.format(msg=msg, text=text, pattern=compiled.pattern))