The YANG W3C Regex Expression validator page was built for YANG developers to check if their expressions are valid. There are already many online regex checkers like regex101.com, but we did not find any that respects the YANG RFC nor the W3C rules.


The tool is a web GUI using two C programs in the backend: YANGRE and W3CGREP. You can navigate between both validators by using the menu.

YANGRE requires patterns as you would write them in a YANG schema. YANGRE takes the pattern, creates a very small YANG schema, validates the schema and checks if the leaf of string type with the specified pattern(s) can have the provided value (if it matches the patterns). So it actually checks what yanglint does in case the string is specified as leaf's default value.

See RFC 7950 section 9.4.5 for details on the YANG regular expressions.

W3CGREP is simply checking the pattern based on W3C rules.


The YANGRE and W3C validators have different ways of dealing with quoting. As an example, W3CGREP will accept the pattern [a-z]{3}, while YANGRE will refuse it stating an error. This is correct per the RFC, since this is an unquoted string. For YANGRE to accept this pattern, you would need to put it into double quotes: "[a-z]{3}" would be accepted.

See RFC 7950 section 6.1.3 for information on quoting for the YANGRE validator.


The validators also have an API

Source code?