codewars_python_solutions
codewars_python_solutions copied to clipboard
New kata-56a3f08aa9a6cc9b75000023
trafficstars
CodeWars Python Solutions
Simple validation of a username with regex
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).
Given Code
def validate_usr(username):
#your code here
Solution
def validate_usr(username):
return re.match('^[a-z0-9_]{4,16}$', username) != None
8kyuKatas