From abdbda5601c2c0ceb4e5b76075c0406c1b3dc47b Mon Sep 17 00:00:00 2001 From: MacTaylor Date: Wed, 14 Jul 2021 21:56:49 +0900 Subject: [PATCH] Fix the problem with regexp with space problem --- shopeego.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shopeego.go b/shopeego.go index cb345a7..727d9f1 100644 --- a/shopeego.go +++ b/shopeego.go @@ -521,11 +521,11 @@ func (s *ShopeeClient) post(method string, in interface{}) ([]byte, error) { func (s *ShopeeClient) patchFloat(body []byte) []byte { replaceConcat := strings.Join(replaces, "|") for _, v := range replaces { - body = []byte(strings.ReplaceAll(string(body), fmt.Sprintf(`"%s": ""`, v), fmt.Sprintf(`"%s": "0"`, v))) + body = []byte(strings.ReplaceAll(string(body), fmt.Sprintf(`"%s":""`, v), fmt.Sprintf(`"%s":"0"`, v))) } - var r = regexp.MustCompile(fmt.Sprintf(`"(%s)": ([^"].*?)(,|})`, replaceConcat)) - return []byte(r.ReplaceAllString(string(body), `"$1": "$2"$3`)) + var r = regexp.MustCompile(fmt.Sprintf(`"(%s)":([^"].*?)(,|})`, replaceConcat)) + return []byte(r.ReplaceAllString(string(body), `"$1":"$2"$3`)) } //=======================================================