def wildcard_to_regexp(instring):
 regexp_string = ''
 if (instring[0] != '*'):
  regexp_string += '^'
 regexp_string += instring.replace('*', '(.*)').replace('?', '(.{1})')
 if (instring[(-1)] != '*'):
  regexp_string += '$'
 return regexp_string

def wildcard_to_regexp ( instring ) : regexp_string = '' if ( instring [ 0 ] != '*' ) : regexp_string += '^' regexp_string += instring . replace ( '*' , '(.*)' ) . replace ( '?' , '(.{1})' ) if ( instring [ ( - 1 ) ] != '*' ) : regexp_string += '$' return regexp_string
converts a player-supplied string that may have wildcards in it to regular expressions .