From ce9ee3fa6e643af29979a08cd40337ad45a5d1a0 Mon Sep 17 00:00:00 2001 From: "chen.s.g" Date: Mon, 10 Sep 2018 15:21:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B0=8F=E6=95=B0=E7=82=B9?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- format.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/format.go b/format.go index 13f0434..c0405db 100644 --- a/format.go +++ b/format.go @@ -80,6 +80,7 @@ type Format struct { // Prepare format meta data func (f *Format) Prepare() { var regexColor = regexp.MustCompile("^\\[[a-zA-Z]+\\]") + var regexSharp = regexp.MustCompile("^\\d+\\.?\\d?#+") var regexFraction = regexp.MustCompile("#\\,?#*") for k, v := range f.Raw { @@ -100,6 +101,11 @@ func (f *Format) Prepare() { // strip color information v = regexColor.ReplaceAllString(v, "") + // replace 0.0#### as 0.00000 + if regexSharp.MatchString(v) { + v = strings.Replace(v, "#", "0", -1) + } + // Strip # v = regexFraction.ReplaceAllString(v, "") @@ -127,7 +133,9 @@ func (f *Format) Prepare() { if f.bts > 0 { f.bts = f.bts - 1 } - } else if t := strings.Index(f.Raw[0], "General"); t > 0 { + } else if t := strings.Index(f.Raw[0], "General"); -1 != t { + f.bts = -1 + } else if t := strings.Index(f.Raw[0], "@"); -1 != t { f.bts = -1 } }