RFC 1766 language tags consist of a primary tag and zero or more subtags, all connected by hyphens. The primary and all secondary tags are permitted by the syntax to be between 1 and 8 characters although at this time no primary tags longer than two characters exist. The first sub-tag, if it exists and is exactly two charcters, must be an ISO country code.
Language tags are case insensitive.
Part of the idea is that if an exact match is not available, some subtags can be discarded to get a less exact language match which will probably still be comprehensible. Although long language tags would probably be rare, I suggest that allowance be made for up to a maximum length primary tag and three subtags. That would be a length range of from 1 to 35 characters.