简体   繁体   English

如何在Yang模型中对字符串模式进行限制

[英]How to put restrictions on Pattern of String in Yang Model

how can we design the string pattern if i want to allow special characters (#@$%) also to be included in the value for Name. 如果我想允许特殊字符(#@ $%)也包含在Name的值中,我们如何设计字符串模式。

For Ex. 对于前 All the below ones are valid entries for Name 以下所有都是“姓名”的有效条目

Name = aaa990ZX 名称= aaa990ZX

Name = a@#9980XS 名称= a @#9980XS

Name = $$$$$$$$ 名称= $$$$$$$$

Name = 00000000 名称= 00000000

typedef Name {
     type string {
         pattern [a-zA-Z0-9];
     }
description
 "Value " ;
}

YANG uses the XSD schema regular expression flavor to define such constraints. YANG使用XSD架构正则表达式来定义此类约束。 Simply define and expression such as: 只需定义和表达,例如:

pattern '[a-zA-Z0-9#@$%]+';

It is recommended to use a single quote string to define a YANG pattern statement argument in order to avoid escape sequence problems. 建议使用单引号字符串定义YANG pattern语句自变量,以避免转义序列问题。

The exact specification of acceptable regular expressions may be found here . 可以在此处找到可接受的正则表达式的确切说明。

I suggest you read up on regular expressions and perhaps look for a tutorial on it. 我建议您阅读正则表达式,或者寻找有关它的教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM