String Pattern with ^ and $

Hi team,
For the pattern in YANG file like following, when I access netconf for such leaf, I need to have ^ and $ at the string beginning and end. What’s the reason I need to input the ^ and $ in xml for such type of string?
typedef date-and-time {
type string {
pattern
‘^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}’ +
‘(.[0-9]+)?Z[±][0-9]{2}:[0-9]{2}$’;
}
}

What I need to use it in xml file:
^2019-11-19T06:30:33Z+08:00$

The reason is that the YANG module you are using uses non-compliant regular expression. YANG RFC requires use of XML-Schema regular expressions, whereas the module - I assume it is openconfig-yang-types - uses POSIX regular expressions. One notable differences between the two standards is in the use of "^" and "$" characters - in POSIX they serve as anchors, denoting the start and end of the match, in XML-schema they are just plain characters as expressions are anchored implicitly. In other words, the regular expression you pasted means something different as a POSIX regex - an anchored datetime string; and something different as YANG-standard XML-Schema regex - a datetime string delimited by "^" and "$".

This is unfortunately just one of many issues with OpenConfig YANG modules. If you need to stick with OpenConfig, this particular issue is still relatively easy to deal with. One option is to just modify the module before compilation, and depending on how you integrate with other components, this may be good enough. Other options is to use already existing compile-time yanger plugin that fixes exactly this problem; the plugin will be part of the confd-7.4 release.

But again, you may expect other problems if you use OpenConfig modules.

Thanks, I got the reason.
Yes, right now I need to stick with OpenConfig. So looks like the best solution is to modify the module.