// retoor <retoor@molodetz.nl>
import "regex" for Regex, Match
System.print(Regex.test("\\d+", "abc123def")) // expect: true
System.print(Regex.test("\\d+", "no digits")) // expect: false
System.print(Regex.test("^hello", "hello world")) // expect: true
System.print(Regex.test("^hello", "say hello")) // expect: false
var m = Regex.match("(\\w+)-(\\d+)", "item-42")
System.print(m.text) // expect: item-42
System.print(m[1]) // expect: item
System.print(m[2]) // expect: 42
var m2 = Regex.match("notfound", "some text")
System.print(m2 == null) // expect: true
System.print(Regex.replace("a", "banana", "o")) // expect: bonono
System.print(Regex.replace("\\d", "a1b2c3", "X")) // expect: aXbXcX
System.print(Regex.replace("notfound", "original", "X")) // expect: original
var parts = Regex.split(",", "a,b,c")
System.print(parts.count) // expect: 3
System.print(parts[0]) // expect: a
System.print(parts[1]) // expect: b
System.print(parts[2]) // expect: c
var parts2 = Regex.split(" ", "one two three")
System.print(parts2.count) // expect: 3
System.print(parts2[0]) // expect: one
System.print(parts2[1]) // expect: two
System.print(parts2[2]) // expect: three
var parts3 = Regex.split("x", "no match")
System.print(parts3.count) // expect: 1
System.print(parts3[0]) // expect: no match