Skip to content

Commit

Permalink
text: AlignAuto uses strconv.ParseFloat instead of RegExp
Browse files Browse the repository at this point in the history
  • Loading branch information
jedib0t committed Mar 14, 2024
1 parent 8380d26 commit 516c996
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion text/align.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ var (
func (a Align) Apply(text string, maxLength int) string {
aComputed := a
if aComputed == AlignAuto {
if reNumericText.MatchString(text) {
_, err := strconv.ParseFloat(text, 64)
if err == nil { // was able to parse a number out of the string
aComputed = AlignRight
} else {
aComputed = AlignLeft
Expand Down

0 comments on commit 516c996

Please sign in to comment.