Skip to content

Commit

Permalink
修复小数点问题
Browse files Browse the repository at this point in the history
  • Loading branch information
chen.s.g committed Sep 10, 2018
1 parent 8d4bc34 commit ce9ee3f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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, "")

Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit ce9ee3f

Please sign in to comment.