Syl
Syl

Reputation: 2232

Regex with at least 3 alpha and allows numerics and specials chars

The regexp what i'm searching for is :

Examples :

test1546 = OK

vqa._96 = OK

1test_ = KO

_test1546 = KO

Thank's a lot! ;)

Upvotes: 1

Views: 99

Answers (1)

Mark Byers
Mark Byers

Reputation: 839114

Try this regular expression:

/^[a-zA-Z]{3}[\w.-]*$/

Explanation:

  • The ^ matches the start of the string.
  • The $ matches the end of the string.
  • The [a-zA-Z]{3} means match three letters.
  • The \w matches [A-Za-z0-9_].

Upvotes: 4

Related Questions