/^[a-z]{2,3}(?:-[A-Z]{2,3}(?:-[a-zA-Z]{4})?)?$/
Here is how it works
^ <- Starts with
[a-z] <- From a to z (lower-case)
{2,3} <- Repeated at least 2 times, at most 3
(?: <- Non capturing group
- <- The "-" character
[A-Z] <- From a to z (upper-case)
{2,3} <- Repeated at least 2 times, at most 3
(?: <- Non capturing group
- <- The "-" character
[a-zA-Z] <- from a to Z (case insensitive)
{4} <- Repeated 4 times
) <- End of the group
? <- Facultative
) <- End of the group
? <- Facultative
$ <- Ends here
No comments:
Post a Comment