Skip to content

Commit ce9ee3f

Browse files
author
chen.s.g
committed
修复小数点问题
1 parent 8d4bc34 commit ce9ee3f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

format.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ type Format struct {
8080
// Prepare format meta data
8181
func (f *Format) Prepare() {
8282
var regexColor = regexp.MustCompile("^\\[[a-zA-Z]+\\]")
83+
var regexSharp = regexp.MustCompile("^\\d+\\.?\\d?#+")
8384
var regexFraction = regexp.MustCompile("#\\,?#*")
8485

8586
for k, v := range f.Raw {
@@ -100,6 +101,11 @@ func (f *Format) Prepare() {
100101
// strip color information
101102
v = regexColor.ReplaceAllString(v, "")
102103

104+
// replace 0.0#### as 0.00000
105+
if regexSharp.MatchString(v) {
106+
v = strings.Replace(v, "#", "0", -1)
107+
}
108+
103109
// Strip #
104110
v = regexFraction.ReplaceAllString(v, "")
105111

@@ -127,7 +133,9 @@ func (f *Format) Prepare() {
127133
if f.bts > 0 {
128134
f.bts = f.bts - 1
129135
}
130-
} else if t := strings.Index(f.Raw[0], "General"); t > 0 {
136+
} else if t := strings.Index(f.Raw[0], "General"); -1 != t {
137+
f.bts = -1
138+
} else if t := strings.Index(f.Raw[0], "@"); -1 != t {
131139
f.bts = -1
132140
}
133141
}

0 commit comments

Comments
 (0)