generate functionMon, 23 Jan 2023

Assert that a string has only lowercase alphanumeric characters and hyphens but no other special characters with a max length of 255 chars

def is_slug(string): if len(string) > 255: return False pattern = re.compile("^[a-z0-9-]+$") if pattern.match(string) is None: return False return True

Questions about programming?Chat with your personal AI assistant