修复小数点问题
This commit is contained in:
parent
8d4bc34c4d
commit
ce9ee3fa6e
10
format.go
10
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
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user