free stats

How to write regex to validate username with javascript

Asked 1 years ago in General Programming by Karmand Taher Answer


Hi all,

I have to validate the username in one of my projects with this format AAAAA_000000.

Here,

  • A = represents any character
  • 0 = represents any number.

How can I do this task with javascript?


1 Answer

Answered 1 years ago by Margo Shogren


Try the following regular expression to validate your usernames.

/[a-zA-Z]{8}[_]{1}[0-9]{7}$/g
Add Your Answer

Answer Preview

By clicking "Post your answer", you agree to the terms,conditions and privacy policy of UXPython.com Terms & Conditions