diff --git a/dsl/matcher.go b/dsl/matcher.go index f0e84a147..d24ae57fd 100644 --- a/dsl/matcher.go +++ b/dsl/matcher.go @@ -412,7 +412,7 @@ func pluckParams(srcType reflect.Type, pactTag string) params { if _, err := fmt.Sscanf(components[0], "example=%s", ¶ms.str.example); err != nil { triggerInvalidPactTagPanic(pactTag, err) } - params.str.regEx = strings.Replace(components[1], `\`, `\\`, -1) + params.str.regEx = components[1] } else if exampleRegex.Match([]byte(pactTag)) { components := strings.Split(pactTag, "example=") diff --git a/dsl/matcher_test.go b/dsl/matcher_test.go index cc67ad86c..986c9c233 100644 --- a/dsl/matcher_test.go +++ b/dsl/matcher_test.go @@ -617,7 +617,7 @@ func TestMatch(t *testing.T) { src: dateDTO{}, }, want: StructMatcher{ - "date": Term("2000-01-01", `^\\d{4}-\\d{2}-\\d{2}$`), + "date": Term("2000-01-01", `^\d{4}-\d{2}-\d{2}$`), }, }, { @@ -863,7 +863,7 @@ func Test_pluckParams(t *testing.T) { }, str: stringParams{ example: "33", - regEx: `\\d{2}`, + regEx: `\d{2}`, }, }, },