# TODO: revert to cue eval -i post fix for #1786
! exec cue eval regexp.cue
cmp stderr expect-stderr

-- frontmatter.toml --
title = "Regular expressions"
description = ""

-- text.md --
The `=~` and `!~` operators can be used to check against regular expressions.

The expression `a =~ b` is true if `a` matches `b`, while
`a !~ b` is true if `a` does _not_ match `b`.

Just as with comparison operators, these operators may be used
as unary versions to define a set of strings.

-- regexp.cue --
a: "foo bar" =~ "foo [a-z]{3}"
b: "maze" !~ "^[a-z]{3}$"

c: =~"^[a-z]{3}$" // any string with lowercase ASCII of length 3

d: c
d: "foo"

e: c
e: "foo bar"

-- expect-stderr --
e: invalid value "foo bar" (out of bound =~"^[a-z]{3}$"):
    ./regexp.cue:4:4
    ./regexp.cue:9:4
    ./regexp.cue:10:4
