From ed8b77c704cbd15f5c2ab1d06bb20bee8f0008f1 Mon Sep 17 00:00:00 2001 From: Joseph Kato Date: Sat, 2 Oct 2021 16:46:42 -0700 Subject: [PATCH] RE2 mode --- std.go | 2 +- std_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/std.go b/std.go index e11b661..f9ebfdf 100644 --- a/std.go +++ b/std.go @@ -1,7 +1,7 @@ package regexp2 func CompileStd(s string) (*Regexp, error) { - return Compile(s, Multiline) + return Compile(s, RE2) } func MustCompileStd(s string) *Regexp { diff --git a/std_test.go b/std_test.go index 6074137..bca2a86 100644 --- a/std_test.go +++ b/std_test.go @@ -146,6 +146,20 @@ func TestFindAllStringSubmatchIndex(t *testing.T) { if !reflect.DeepEqual(a1, a2) { t.Fatalf("Failed: %v, %v", a1, a2) } + + /* FIXME: There's a disconnect between rune/byte offets + + re1 = regexp.MustCompile(`(?m)(?:(?P[”“]))`) + re2 = MustCompileStd(`(?m)(?:(?P[”“]))`) + + s := `(smart or “curly” quotes).` + + a1 = re1.FindAllStringSubmatchIndex(s, -1) + a2 = re2.FindAllStringSubmatchIndex(s, -1) + + if !reflect.DeepEqual(a1, a2) { + t.Fatalf("Failed: %v, %v", a1, a2) + }*/ } func TestSubexpNames(t *testing.T) {