20
0

修复小数点问题

This commit is contained in:
chen.s.g 2018-09-10 15:21:11 +08:00
parent 8d4bc34c4d
commit ce9ee3fa6e

View File

@ -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
}
}