Skip to content

Commit

Permalink
support more cell format syntax (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
alicebob authored Apr 21, 2021
1 parent 55afc33 commit 39d7714
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func getFormatCode(ID int, numberFormats []numberFormat) string {
return ""
}

var formatGroup = regexp.MustCompile(`\[.+\]`)
var formatGroup = regexp.MustCompile(`\[.+?\]|\\.|".*?"`)

// isDateFormatCode determines whether a format code is for a date.
func isDateFormatCode(formatCode string) bool {
Expand Down
7 changes: 7 additions & 0 deletions styles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ var dateFormatCodeTests = []struct {
{"potato", false},
{"0;[Red]0", false},
{"[Blue][<=100];[Blue][>100]", false},
{"[mm]:ss", true},
{"[Red]hh:dd;[Red]", true},
{"0.00E+00", false},
{`0.00" YYY"`, false},
{`"Y"YYYY"Y"`, true},
{`0.00\Y`, false},
{`YYYY\YYYYY`, true},
{"", false},
}

Expand Down

0 comments on commit 39d7714

Please sign in to comment.