Underscore in regex pattern for a leaf

I believe your YANG regular expressions need to have an escape “/” character in front of characters that belong to the single character escape group when that type of character, which includes the “^” character, are to be interpreted as a character that belong to the positive character group. See first the definition of the positive character group:

https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#nt-posCharGroup

Definition of where the unescaped “^” character is valid:

The ^ character is only valid at the beginning of a ·positive character group· if it is part of a ·negative character group·

https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#nt-charRange

The definition of the characters that need to be escaped to not have a special meaning:

A single character escape identifies a set containing a only one character – usually because that character is difficult or impossible to write directly into a ·regular expression·.

https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#dt-cces1