Skip to content

Commit

Permalink
Fix lint warning, more clearly regexp rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Dec 4, 2019
1 parent b48c4a0 commit 2f301c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions paragraph.go
Expand Up @@ -7,9 +7,9 @@ import (
)

var (
splacesRegexp = regexp.MustCompile("[ ]+")
allowCharsRegexp = regexp.MustCompile("[a-zA-Z0-9\\.,\\?\\!;\\(\\)\\[\\]\\&\\=\\-_@ ]")
hansMarks = map[string]string{
splacesRegexp = regexp.MustCompile(`[\s]+`)
allowCharsRegexp = regexp.MustCompile(`[a-zA-Z0-9\.,\?\!;\(\)\[\]\&\=\-_@\s]`)
hansSymbols = map[string]string{
"?": "?",
"!": "!",
":": ":",
Expand Down Expand Up @@ -40,8 +40,8 @@ func ParagraphPinyin(p string) (s string) {
if allowCharsRegexp.MatchString(char) {
s += char
} else {
if hansMarks[char] != "" {
s += hansMarks[char]
if hansSymbols[char] != "" {
s += hansSymbols[char]
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pinyin.go
Expand Up @@ -94,8 +94,8 @@ var finalExceptionsMap = map[string]string{
"ǔ": "ǚ",
"ù": "ǜ",
}
var reFinalExceptions = regexp.MustCompile("^(j|q|x)(ū|ú|ǔ|ù)$")
var reFinal2Exceptions = regexp.MustCompile("^(j|q|x)u(\\d?)$")
var reFinalExceptions = regexp.MustCompile(`^(j|q|x)(ū|ú|ǔ|ù)$`)
var reFinal2Exceptions = regexp.MustCompile(`^(j|q|x)u(\d?)$`)

// NewArgs 返回包含默认配置的 `Args`
func NewArgs() Args {
Expand Down

0 comments on commit 2f301c2

Please sign in to comment.