How to define a string pattern that doesn't include a substring

I would like define a string pattern that doesn’t include a substring “last-as”.
leaf test2 {
tailf:cli-multi-value;
type string {
pattern ‘^(?!.last-as).’;
}
}
I have got the following when compile
error: invalid pattern: “Bad Pattern”
looks like negative lockahead ?! is not working for yang.
please help.

Shibin

You can do something like the following:

leaf no-last-as {
  type string {
    pattern "[-_0-9a-zA-Z]*";
    pattern ".*last-as.*" {
      modifier invert-match;
    }
  }
}

This allows any string value consisting of alphanumeric characters plus '-' and '_' that does not include the string "last-as". Note that the modifier statement requires that you use yang-version 1.1.