Regular expression with an empty branch at the end is not considered valid
The pattern "(([a-zA-Z0-9_]+)(;[a-zA-Z0-9_]+))|" is not considered valid. See attached small example libxml2_pattern_bug.zip.
The regular expression language of XML Schema is defined as (see https://www.w3.org/TR/xmlschema-2/#dt-regex):
regExp ::= branch ( '|' branch )*
branch ::= piece*
As "branch" may be empty, I see no reason why a pattern can't end with "|". Also, Altova XMLSpy, .NET XML Parser and Apache Xerces XML parser consider this valid.
After moving the "|" to the front, the pattern is considered valid, but an empty string is still not accepted.
After rewriting the pattern as "([0-9a-zA-Z_]+;)([0-9a-zA-Z_]+)?", the validation worked. (But it's not exactly the same check; it now accepts strings that end with ";".)