Skip to main content

is_valid_locale

Validates whether a given locale string matches a specific format using regular expressions.

def is_valid_locale(
locale: string
) - > re.Match | None

Validates whether a given string conforms to a standard locale format, ensuring it matches either a simple language code or a language-region combination.

Parameters

NameTypeDescription
localestringThe locale identifier string to be validated, such as a language code or a language-country pair.

Returns

TypeDescription
`re.MatchNone`