fix
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package processing
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Glue between a lowercase letter and an UPPERCASE model token
|
||||
// (e.g. "hladilnikGSXV80PZLE" → "hladilnik GSXV80PZLE").
|
||||
// Digits are excluded from the left side so "GSXV80PZLE" is not split at "0P".
|
||||
var reGlueUpperModel = regexp.MustCompile(`(\p{Ll})([\p{Lu}][\p{Lu}\p{Nd}]{2,})`)
|
||||
|
||||
// ensureReadableTitleSpacing inserts missing spaces before glued model codes and
|
||||
// collapses whitespace. Safe for already-spaced retail titles.
|
||||
func ensureReadableTitleSpacing(title string) string {
|
||||
title = strings.TrimSpace(title)
|
||||
if title == "" || title == "<nil>" {
|
||||
return title
|
||||
}
|
||||
out := reGlueUpperModel.ReplaceAllString(title, "$1 $2")
|
||||
return strings.Join(strings.Fields(out), " ")
|
||||
}
|
||||
Reference in New Issue
Block a user