package regexp2 import ( "strconv" "testing" ) func TestReplace_Basic(t *testing.T) { re := MustCompile(`test`, 0) str, err := re.Replace("this is a test", "unit", -1, -1) if err != nil { t.Fatalf("Unexpected err: %v", err) } if want, got := "this is a unit", str; want != got { t.Fatalf("Replace failed, wanted %v, got %v", want, got) } } func TestReplace_NamedGroup(t *testing.T) { re := MustCompile(`[^ ]+\s(?