0

how can we design the string pattern if i want to allow special characters (#@$%) also to be included in the value for Name.

For Ex. All the below ones are valid entries for Name

Name = aaa990ZX

Name = a@#9980XS

Name = $$$$$$$$

Name = 00000000

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

1 Answers1

3

YANG uses the XSD schema regular expression flavor to define such constraints. 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.

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.

predi
  • 5,528
  • 32
  • 60