example/type.regex.primi
_ = "Default value for regex is empty regex"
default = regex()
assert(default == rx'', _)
a = rx"[a-z]/[a-z]"
b = "ahojkymňauky"
c0 = 0
if (b == a) {
c0 = 1
}
if (a == b) {
c0 = 1
}
assert(c0 == 0)
a = rx"[abc][čřž][xyz]{4,}"; b = 'ačxxx'; c1 = 0
if (b == a or a == b) {
c1 = 1
}
if (b == a or a == b) {
c1 = 1
}
assert(c1 == 0)
a = rx"[abc][čřž][xyz]{4,}"; b = 'ačxxxx'; c2 = 0
if (b == a or a == b) {
c2 = c2 + 1
}
if (b == a or a == b) {
c2 = c2 + 1
}
assert(c2 == 2)
a = rx"[abc][čřž][xyz]{4,}"; b = 'cžxyzx'; c3 = 0
if (b == a and a == b) {
c3 = c3 + 2
}
if (b == a and a == b) {
c3 = c3 + 2
}
assert(c3 == 4)
a = rx"[abc][čřž][xyz]{4,}"; b = 'cžvole'; c4 = 0
if (b != a and a != b) {
c4 = c4 + 3
}
if (b != a or a != b) {
c4 = c4 + 3
}
assert(c4 == 6)
str_a = "abcdefg"
str_b = "abc123defg"
str_c = "xyz456čaukomňauko"
x = str_a == rx"[cde]d"
assert(x == true)
x = rx"[cde]d" == str_a
assert(x == true)
x = rx"(\d+|[A-Z])" != str_a
assert(x == true)
x = "what have we here" != rx"h[abc]v[def]"
assert(x == false)
rx_i = rx"[c-e]"
assert(rx_i == rx"[c-e]")
rx_j = rx"[ce]"
assert(rx_j == rx"[ce]")
rx_k = rx"[0-9]+"
assert(rx_k == rx"[0-9]+")
rx_l = rx"[čau](ko)+mňau"
assert(rx_l == rx"[čau](ko)+mňau")
x = str_a - rx_i
assert(x == "abfg")
x = str_a - rx_j
assert(x == "abdfg")
x = str_b - rx_i
assert(x == "ab123fg")
x = str_b - rx_j
assert(x == "ab123dfg")
x = str_c - rx_k
assert(x == "xyzčaukomňauko")
x = str_c - rx_l
assert(x == "xyz456čako")
x = "xoxoxomilanobergamo,anno:domini. Anno, neštvi ma.".replace(rx"ann?o", "FAIL")
assert(x == "xoxoxomilFAILbergamo,FAIL:domini. Anno, neštvi ma.")
x = "\\ahoj\n\\vo\\le" - rx"\\ahoj\s"
assert(x == "\\vo\\le")
x = "a/b/c" - rx"/b" // Test proper handling of escaped regex delimiters.
assert(x == "a/c")
x = regex("[0-9]{5}").find("abc00011234455")
assert(x == "00011")
x = regex("[0-9]+").find("abc00011234455")
assert(x == "00011234455")
x = regex("[{}-{}]".format(0, 9)).find("abc123")
assert(x == "1")
x = regex("{}-{}".format(0, 9)).find("abc")
assert(x == false)