본문 바로가기
알고리즘/Codewars

[Codewars] Simple validation of a username with regex (8 kyu) / JavaScript

by fluss 2023. 4. 25.

https://www.codewars.com/kata/56a3f08aa9a6cc9b75000023

 

Codewars - Achieve mastery through coding practice and developer mentorship

A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!

www.codewars.com

 

DESCRIPTION:

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).

 

코드

function validateUsr(username) {
  res = /^[0-9a-z_]{4,16}$/.test(username)
  return res
}

댓글