I am trying to create a regex in yang model to not allow * and ? characters. String * and ? should not be allowed as input.
.e.g. - abc* - should be okay
- * - is not okay and should be rejected
Similarly string ("?") should be rejected.
Tried my hand with regex '[^?]+' which is rejecting any string with any occurrence of * and ?. .e.g abc*, *abc, * and ? all of them are rejected.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
YANG uses the XML Schema (XSD) flavor of regular expressions, but this case would be similar in most flavors. If I understand correctly, you wish to prohibit a string to start with characters *
and ?
.
[^*?].*
The above says: the string always has at least one character, where the first character may be any character except *
or ?
and may be followed by any number of arbitrary characters.
You can read more about the specifics of YANG regular expressions here. Do note that there are subtle differences between regexes defined in different versions of XSD Schema and that YANG relies on the one defined in normative references section of RFC7950 (and RFC6020).
标签:
ietf-netmod-yang