0

I really need a JavaScript username regex as:

  • must start with a letter
  • from 5-20 characters.
  • allows the following special characters after the first letter: _-.@
  • allows for all letters and numbers after the first character (including accented characters).

I am pretty new to regex, and I read this which seems sort of close:

/^[a-zA-Z][a-zA-Z\d-_\.@]+$/ 

but it does not allow for accented characters (i.e. é) after the first character.

karel
  • 5,489
  • 46
  • 45
  • 50
Eric Sebasta
  • 225
  • 1
  • 7
  • 3
    Hint: You can't write a regular expression to check for "accented and whatnot". You're going to have to figure out a lot more clearly what your rules are. – Sam Hanley May 13 '14 at 18:32
  • that explains how to allow any utf8 characters in a regex... and would not follow any of the other criteria. I am only interested in the European accents and regular letters within the other rules, but I am stumbling through this and every time I try to allow those characters, I am breaking my other rules somehow. – Eric Sebasta May 13 '14 at 18:48
  • as I said... utf8 covers a LOT more then what I need to check for including RTL characters, chinese, and things nobody in europe or america can even toss out of a keyboard... so this certainly is not a duplicate question, because the answer is horrible overkill and not relevent to the problem at hand. :) – Eric Sebasta Jul 25 '14 at 18:25
  • You said you want "all letters and numbers [...] including accented characters". The operative word there is "all". Since you didn't take the suggestion to clarify the subset of characters you want to support, inferring that what you want is to support utf-8 is not an inaccurate reading of what you said. – Sam Hanley Jul 25 '14 at 18:54

0 Answers0