Skip to main content
AllDevToolsHub
Back to all patterns

ISO 639-1 Language Code

Validation

Matches a 2-letter language code with optional region (en, en-US, pt-BR).

/^[a-z]{2}(?:-[A-Z]{2})?$/

How it works

BCP-47 language tags often start with an ISO 639-1 2-letter code, optionally followed by an ISO 3166 region. This is the common simple shape; full BCP-47 is much richer.

Test Cases

Should Match

  • en
  • en-US
  • pt-BR
  • zh-CN

Should NOT Match

  • EN
  • english
  • en-us

Quick Summary

Matches simple BCP-47 language tags: lower-case language + optional upper-case region.