2024-06-05 18:09:27 -08:00
|
|
|
|
package str
|
2016-02-29 09:56:09 -09:00
|
|
|
|
|
|
|
|
|
|
import (
|
2016-03-02 09:18:39 -09:00
|
|
|
|
"strings"
|
2016-02-29 09:56:09 -09:00
|
|
|
|
)
|
|
|
|
|
|
|
2024-06-06 03:09:30 -08:00
|
|
|
|
var utf8ToAscii = strings.NewReplacer(
|
|
|
|
|
|
"–", "-",
|
|
|
|
|
|
"‐", "-",
|
|
|
|
|
|
"“", `"`,
|
|
|
|
|
|
"”", `"`,
|
|
|
|
|
|
"‘", `'`,
|
|
|
|
|
|
"’", `'`,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2024-06-05 18:09:27 -08:00
|
|
|
|
func Clear(name string) string {
|
2024-06-06 03:09:30 -08:00
|
|
|
|
return utf8ToAscii.Replace(name)
|
2024-06-05 18:09:27 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-17 06:27:30 -08:00
|
|
|
|
func LongestCommonPrefix(list []string) string {
|
|
|
|
|
|
if len(list) == 0 {
|
|
|
|
|
|
return ""
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for l := 0; l < len(list[0]); l++ {
|
|
|
|
|
|
c := list[0][l]
|
|
|
|
|
|
for i := 1; i < len(list); i++ {
|
|
|
|
|
|
if l >= len(list[i]) || list[i][l] != c {
|
|
|
|
|
|
return list[i][0:l]
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return list[0]
|
|
|
|
|
|
}
|