ietf-language-tag-regex

Regular expressions for matching IETF language tags (BCP 47)

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
ietf-language-tag-regex
710.0.56 years ago6 years agoMinified + gzip package size for ietf-language-tag-regex in KB

Readme

ietf-language-tag-regex
Regular expressions for matching IETF language tags (BCP 47)

Based on this Stack Overflow comment by George Pollard.

Install

Usage

const languageTagRegex = require('ietf-language-tag-regex')

languageTagRegex().test('en-GB')   // true
languageTagRegex().test('a-DE')    // false
languageTagRegex().test('zh-Hant') // true

API

languageTagRegex(options)

Returns a regex for matching IETF language tags.

options

exact
Type: boolean
Default: true
Only match an exact string. Useful with RegExp#test to check if a string is a language tag.