github.com/solo-io/cue@v0.4.7/doc/tutorial/basics/6_expressions/70_regexp.txt (about)

     1  cue eval -i regexp.cue
     2  cmp stdout expect-stdout-cue
     3  
     4  -- frontmatter.toml --
     5  title = "Regular expressions"
     6  description = ""
     7  
     8  -- text.md --
     9  The `=~` and `!~` operators can be used to check against regular expressions.
    10  
    11  The expression `a =~ b` is true if `a` matches `b`, while
    12  `a !~ b` is true if `a` does _not_ match `b`.
    13  
    14  Just as with comparison operators, these operators may be used
    15  as unary versions to define a set of strings.
    16  
    17  -- regexp.cue --
    18  a: "foo bar" =~ "foo [a-z]{3}"
    19  b: "maze" !~ "^[a-z]{3}$"
    20  
    21  c: =~"^[a-z]{3}$" // any string with lowercase ASCII of length 3
    22  
    23  d: c
    24  d: "foo"
    25  
    26  e: c
    27  e: "foo bar"
    28  
    29  -- expect-stdout-cue --
    30  a: true
    31  b: true
    32  c: =~"^[a-z]{3}$"
    33  d: "foo"
    34  e: _|_ // invalid value "foo bar" (does not match =~"^[a-z]{3}$")