Battle-Tag Regex Expression

I have recreated the Battle-Tag Check using Regex:

(^([A-zÀ-ú][A-zÀ-ú0-9]{2,11})|(^([а-яёА-ЯЁÀ-ú][а-яёА-ЯЁ0-9À-ú]{2,11})))(#[0-9]{4,})$

Rules:
Quite large, huh? So by testing and researching, I was able to find these rules:

  • Numbers allowed, except for the first Letter
  • Latin Alphabet or Cyrillic alphabet, but not a mixture
  • Accented Letters are allowed in both situations
  • No spaces or punctuations
  • No Special Characters e.g. #, -, …
  • 3-12 Characters
  • I think the discriminator must be 4-5 numbers, but I kept it to >4 because I didn’t find much information about that

Explanation:
This could be very complicated for some of you, but I will simplify as best as possible:

  • 2 Groups: 1 for Latin Alphabet and 1 for Cyrillic Alphabet
  • I split the first letter from the others because that can’t be a number, but the others can.
  • For the Latin I just used A-z, for the Cyrillic alphabet I searched for a table of that alphabet and used а-я & А-Я. I also threw some characters that worked in (e.g. ё). Last I have inserted À-ú to both sides.

I hope you can use this regex in your projects.
Bye!

2 Likes

Thank you for this! Been looking around :stuck_out_tongue: