2008: International Year of Languages

Addison Phillips Java regexp for language tags

Suitable for the new syntax of the future RFC 4646bis. Written by Addison Phillips, addison - at - yahoo-inc.com.

         String regex =
             "([xX]([\\x2d]\\p{Alnum}{1,8})*)|((\\p{Alpha}{2,8})"
             + "([\\x2d](\\p{Alpha}{4}))?"
             + "([\\x2d](\\p{Alpha}{2}|\\d{3}))?"
             + "([\\x2d]((\\d\\p{Alnum}{3})|(\\p{Alnum}{5,8})))*"
             + "(([\\x2d]([a-wyzA-WYZ])([\\x2d](\\p{Alnum}{2,8})+)*))*"
             + "([\\x2d][xX]([\\x2d]\\p{Alnum}{1,8})*)?)";