If you want to follow the RFC 4646 format for the name of the culture (who <languagecode2>-<country/regioncode2>, where <languagecode2>is the language code and <country/regioncode2>is the subculture code)
Example : "en", "en-UK", "fr", "fr-FR", ...
Use this regex:
^[a-z]{2}(-[A-Z]{2})*
C # code example
Regex.IsMatch(culture, @"^[a-z]{2}(-[A-Z]{2})*$")
source
share