Language

The first and only parameter accepted by the CSS3 :lang() pseudo-class does not need to be a valid language tag per [BCP47]; it only needs to be a valid CSS 2.1 identifier. However, because BCP 47 is the system used by TEI to indicate language (on xml:lang), use of other language identifiers in this context does not make sense. Thus the generated regular expression requires a BCP 47 language tag as the parameter to :lang().

Rather than re-invent this particular wheel, I guessed that others had already written a regular expression that would match a BCP 47 tag. Indeed I found more than one readily available on the web. The program currently uses a regular expression adapted from one made publicly available by its author, Seb Insua, a consultant software engineer based in London.