codewars_python_solutions icon indicating copy to clipboard operation
codewars_python_solutions copied to clipboard

New kata-56a3f08aa9a6cc9b75000023

Open DavidAdamsDesign opened this issue 3 years ago • 1 comments
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

See on CodeWars.com

DavidAdamsDesign avatar Aug 29 '22 21:08 DavidAdamsDesign

8kyuKatas

DavidAdamsDesign avatar Aug 29 '22 21:08 DavidAdamsDesign