Skip to content

Commit

Permalink
Merge pull request dop251#143 from MStoykov/fix/142
Browse files Browse the repository at this point in the history
Use strings.Trim instead of regex to trim unicodeString
  • Loading branch information
dop251 authored Apr 9, 2020
2 parents 2de61b1 + 7bb4acf commit 0cd29d8
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions string_unicode.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"io"
"math"
"reflect"
"regexp"
"strings"
"unicode/utf16"
"unicode/utf8"
Expand All @@ -30,10 +29,6 @@ var (
InvalidRuneError = errors.New("Invalid rune")
)

var (
unicodeTrimRegexp = regexp.MustCompile("^[" + parser.WhitespaceChars + "]*(.*?)[" + parser.WhitespaceChars + "]*$")
)

func (rr runeReaderReplace) ReadRune() (r rune, size int, err error) {
r, size, err = rr.wrapped.ReadRune()
if err == InvalidRuneError {
Expand Down Expand Up @@ -96,7 +91,7 @@ func (s unicodeString) toTrimmedUTF8() string {
if len(s) == 0 {
return ""
}
return unicodeTrimRegexp.FindStringSubmatch(s.String())[1]
return strings.Trim(s.String(), parser.WhitespaceChars)
}

func (s unicodeString) ToNumber() Value {
Expand Down

0 comments on commit 0cd29d8

Please sign in to comment.