Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the regex to match an alphanumeric 6 character string?

I need regex for asp.net application to match an alphanumeric string at least 6 characters long.

like image 785
onder Avatar asked Sep 07 '10 11:09

onder


2 Answers

I’m not familiar with ASP.NET. But the regular expression should look like this:

^[a-zA-Z0-9]{6,}$ 

^ and $ denote the begin and end of the string respectively; [a-zA-Z0-9] describes one single alphanumeric character and {6,} allows six or more repetitions.

like image 163
Gumbo Avatar answered Sep 28 '22 02:09

Gumbo


I would use this:

^[\p{L}\p{N}]{6,}$ 

This matches Unicode letters (\p{L}) and numbers (\p{N}), so it's not limited to common letters the Latin alphabet.

like image 42
Fredrik Mörk Avatar answered Sep 28 '22 03:09

Fredrik Mörk