// retoor <retoor@molodetz.nl>
import "regex" for Regex, Match
System.print(Regex.test("hello", "say hello world")) // expect: true
System.print(Regex.test("exact", "exactly")) // expect: true
System.print(Regex.test("h.llo", "hello")) // expect: true
System.print(Regex.test("h.llo", "hallo")) // expect: true
System.print(Regex.test("h.llo", "hllo")) // expect: false
System.print(Regex.test("a..b", "axxb")) // expect: true
System.print(Regex.test("a*", "aaa")) // expect: true
System.print(Regex.test("a*", "aaa")) // expect: true
System.print(Regex.test("ba*", "b")) // expect: true
System.print(Regex.test("ba*", "baaa")) // expect: true
System.print(Regex.test("a+", "a")) // expect: true
System.print(Regex.test("a+", "aaa")) // expect: true
System.print(Regex.test("^a+$", "")) // expect: false
System.print(Regex.test("colou?r", "color")) // expect: true
System.print(Regex.test("colou?r", "colour")) // expect: true
System.print(Regex.test("a{3}", "aaa")) // expect: true
System.print(Regex.test("^a{3}$", "aa")) // expect: false
System.print(Regex.test("a{2,}", "aa")) // expect: true
System.print(Regex.test("a{2,}", "aaaaa")) // expect: true
System.print(Regex.test("a{2,4}", "aaa")) // expect: true
System.print(Regex.test("[abc]", "a")) // expect: true
System.print(Regex.test("[abc]", "b")) // expect: true
System.print(Regex.test("[abc]", "d")) // expect: false
System.print(Regex.test("[a-z]", "m")) // expect: true
System.print(Regex.test("[a-z]", "M")) // expect: false
System.print(Regex.test("[A-Za-z]", "M")) // expect: true
System.print(Regex.test("[0-9]", "5")) // expect: true
System.print(Regex.test("[^abc]", "d")) // expect: true
System.print(Regex.test("[^abc]", "xyz")) // expect: true
System.print(Regex.test("^[^abc]$", "a")) // expect: false
System.print(Regex.test("^hello", "hello world")) // expect: true
System.print(Regex.test("^hello", "say hello")) // expect: false
System.print(Regex.test("world$", "hello world")) // expect: true
System.print(Regex.test("world$", "world hello")) // expect: false
System.print(Regex.test("^exact$", "exact")) // expect: true
System.print(Regex.test("^exact$", "exactly")) // expect: false
System.print(Regex.test("cat|dog", "cat")) // expect: true
System.print(Regex.test("cat|dog", "dog")) // expect: true
System.print(Regex.test("cat|dog", "bird")) // expect: false
System.print(Regex.test("a(bc|de)f", "abcf")) // expect: true
System.print(Regex.test("a(bc|de)f", "adef")) // expect: true
var m = Regex.match("(\\w+)-(\\d+)", "item-42")
System.print(m[1]) // expect: item
System.print(m[2]) // expect: 42
var m2 = Regex.match("((a)(b))", "ab")
System.print(m2[0]) // expect: ab
System.print(m2[1]) // expect: ab
System.print(m2[2]) // expect: a
System.print(m2[3]) // expect: b
System.print(Regex.test("\\d", "5")) // expect: true
System.print(Regex.test("\\d", "a")) // expect: false
System.print(Regex.test("\\D", "a")) // expect: true
System.print(Regex.test("\\D", "5")) // expect: false
System.print(Regex.test("\\w", "a")) // expect: true
System.print(Regex.test("\\w", "_")) // expect: true
System.print(Regex.test("\\w", " ")) // expect: false
System.print(Regex.test("\\W", " ")) // expect: true
System.print(Regex.test("\\W", "a")) // expect: false
System.print(Regex.test("\\s", " ")) // expect: true
System.print(Regex.test("\\s", "\t")) // expect: true
System.print(Regex.test("\\s", "a")) // expect: false
System.print(Regex.test("\\S", "a")) // expect: true
System.print(Regex.test("\\S", " ")) // expect: false
System.print(Regex.test("a\\nb", "a\nb")) // expect: true
System.print(Regex.test("a\\tb", "a\tb")) // expect: true
System.print(Regex.test("a\\rb", "a\rb")) // expect: true
System.print(Regex.test("\\.", ".")) // expect: true
System.print(Regex.test("\\.", "a")) // expect: false
System.print(Regex.test("\\*", "*")) // expect: true
System.print(Regex.test("\\+", "+")) // expect: true
System.print(Regex.test("\\?", "?")) // expect: true
System.print(Regex.test("\\[", "[")) // expect: true
System.print(Regex.test("\\(", "(")) // expect: true
System.print(Regex.test("\\$", "$")) // expect: true
System.print(Regex.test("\\^", "^")) // expect: true