分割商品名尝试修改正则,获取后缀空格

This commit is contained in:
苏尹岚
2020-04-27 18:11:53 +08:00
parent dcf7b87c4d
commit 58737c5a07

View File

@@ -71,7 +71,7 @@ func init() {
// Go regex does not support lookarounds.
// https://stackoverflow.com/questions/38933898/error-parsing-regexp-invalid-or-unsupported-perl-syntax
skuNamePat = regexp.MustCompile(`([\(\[【][^\(\[【\)\]】]*[\)\]】])?(.*?)([(].*[)])?\s*约?([1-9][\d\.]*)(g|G|kg|kG|Kg|KG|l|L|ml|mL|Ml|ML|克)\s*([(].*[)])?\s*(?:\/||)\s*([^\s()]{0,2})\s*([(].*[)])?$`)
skuNamePat = regexp.MustCompile(`([\(\[【][^\(\[【\)\]】]*[\)\]】])?(.*?)([(].*[)])?\s*约?([1-9][\d\.]*)(g|G|kg|kG|Kg|KG|l|L|ml|mL|Ml|ML|克)\s*([(].*[)])?\s*(?:\/||)\s*([^\s()]{0,2})(\s.*)?$\s*([(].*[)])?$`)
emailPat = regexp.MustCompile(`[A-Za-z0-9_\-.]+@(?:[A-Za-z0-9_\-]+\.)+[A-Za-z]+`)
}
@@ -419,6 +419,8 @@ func SplitSkuName(skuName string) (prefix, name, comment, specUnit, unit string,
comment = searchResult[6]
} else if searchResult[8] != "" {
comment = searchResult[8]
} else if searchResult[9] != "" {
comment = searchResult[9]
}
comment = TrimDecorationChar(comment)
name = TrimDecorationChar(searchResult[2])