Generation

generate functionFri, 23 Dec 2022

Write a simple regex to validate a username. Allowed characters are: lowercase letters, numbers, underscore Length should be between 4 and 16 characters (both included).

def validate_usr(username): import re if len(username) < 4 or len(username) > 16: return False else: return bool(re.match("^[a-z0-9_]*$", username))

Questions about programming?Chat with your personal AI assistant