def _match(string, pattern):
p = pattern<EOL>try:<EOL><INDENT>if p[:<NUM_LIT:1>] == WILDCARD and (p[-<NUM_LIT:1>:] == WILDCARD and p[<NUM_LIT:1>:-<NUM_LIT:1>] in string or string.endswith(p[<NUM_LIT:1>:])):<EOL><INDENT>return True<EOL><DEDENT>if p[-<NUM_LIT:1>:] == WILDCARD and not p[-<NUM_LIT:2>:-<NUM_LIT:1>] == "<STR_LIT:\\>" and string.startswith(p[:-<NUM_LIT:1>]):<EOL><INDENT>return True<EOL><DEDENT>if p == string:<EOL><INDENT>return True<EOL><DEDENT>if WILDCARD in p[<NUM_LIT:1>:-<NUM_LIT:1>]:<EOL><INDENT>p = p.split(WILDCARD)<EOL>return string.startswith(p[<NUM_LIT:0>]) and string.endswith(p[-<NUM_LIT:1>])<EOL><DEDENT><DEDENT>except:<EOL><INDENT>if isinstance(p, regexp):<EOL><INDENT>return p.search(string) is not None<EOL><DEDENT><DEDENT>return False<EOL>
Returns True if the pattern matches the given word string.
        The pattern can include a wildcard (*front, back*, *both*, in*side),
        or it can be a compiled regular expression.