Documentation ¶
Overview ¶
Example (Pad) ¶
fmt.Printf("PadLeft=[%s]\n", PadLeftSpace("abc", 7)) fmt.Printf("PadLeft=[%s]\n", PadLeftChar("abc", 7, '-')) fmt.Printf("PadCenter=[%s]\n", PadCenterChar("abc", 7, '-')) fmt.Printf("PadCenter=[%s]\n", PadCenterChar("abcd", 7, '-'))
Output: PadLeft=[ abc] PadLeft=[----abc] PadCenter=[--abc--] PadCenter=[-abcd--]
Example (Sub) ¶
fmt.Printf("Sub-[0:100]=%s\n", Sub("", 0, 100)) fmt.Printf("Sub-facgbheidjk[3:9]=%s\n", Sub("facgbheidjk", 3, 9)) fmt.Printf("Sub-facgbheidjk[-50:100]=%s\n", Sub("facgbheidjk", -50, 100)) fmt.Printf("Sub-facgbheidjk[-3:length]=%s\n", Sub("facgbheidjk", -3, utf8.RuneCountInString("facgbheidjk"))) fmt.Printf("Sub-facgbheidjk[-3:-1]=%s\n", Sub("facgbheidjk", -3, -1)) fmt.Printf("Sub-zh英文hun排[2:5]=%s\n", Sub("zh英文hun排", 2, 5)) fmt.Printf("Sub-zh英文hun排[2:-1]=%s\n", Sub("zh英文hun排", 2, -1)) fmt.Printf("Sub-zh英文hun排[-100:-1]=%s\n", Sub("zh英文hun排", -100, -1)) fmt.Printf("Sub-zh英文hun排[-100:-90]=%s\n", Sub("zh英文hun排", -100, -90)) fmt.Printf("Sub-zh英文hun排[-10:-90]=%s\n", Sub("zh英文hun排", -10, -90))
Output: Sub-[0:100]= Sub-facgbheidjk[3:9]=gbheid Sub-facgbheidjk[-50:100]=facgbheidjk Sub-facgbheidjk[-3:length]=djk Sub-facgbheidjk[-3:-1]=dj Sub-zh英文hun排[2:5]=英文h Sub-zh英文hun排[2:-1]=英文hun Sub-zh英文hun排[-100:-1]=zh英文hun Sub-zh英文hun排[-100:-90]= Sub-zh英文hun排[-10:-90]=
Example (Substart) ¶
fmt.Printf("SubStart-[0:]=%s\n", SubStart("", 0)) fmt.Printf("SubStart-[2:]=%s\n", SubStart("", 2)) fmt.Printf("SubStart-facgbheidjk[3:]=%s\n", SubStart("facgbheidjk", 3)) fmt.Printf("SubStart-facgbheidjk[-50:]=%s\n", SubStart("facgbheidjk", -50)) fmt.Printf("SubStart-facgbheidjk[-3:]=%s\n", SubStart("facgbheidjk", -3)) fmt.Printf("SubStart-zh英文hun排[3:]=%s\n", SubStart("zh英文hun排", 3))
Output: SubStart-[0:]= SubStart-[2:]= SubStart-facgbheidjk[3:]=gbheidjk SubStart-facgbheidjk[-50:]=facgbheidjk SubStart-facgbheidjk[-3:]=djk SubStart-zh英文hun排[3:]=文hun排
Index ¶
- Variables
- func ContainsAnySubstrings(s string, subs []string) bool
- func IsAlpha(s string) bool
- func IsAlphanumeric(s string) bool
- func IsNumeric(s string) bool
- func MustReverse(s string) string
- func PadCenterChar(s string, size int, ch rune) string
- func PadCenterSpace(s string, size int) string
- func PadLeftChar(s string, size int, ch rune) string
- func PadLeftSpace(s string, size int) string
- func PadRightChar(s string, size int, ch rune) string
- func PadRightSpace(s string, size int) string
- func RemoveChar(s string, rmVal rune) string
- func RemoveString(s, rmStr string) string
- func RepeatChar(ch rune, repeat int) string
- func Reverse(s string) (string, error)
- func Rotate(s string, shift int) string
- func Shuffle(s string) string
- func Sub(s string, start, end int) string
- func SubStart(s string, start int) string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrDecodeRune = errors.New("error occurred on rune decoding")
)
Error pre define
Functions ¶
func ContainsAnySubstrings ¶
ContainsAnySubstrings returns whether s contains any of substring in slice.
func IsAlphanumeric ¶
IsAlphanumeric checks if the string contains only Unicode letters or digits.
func IsNumeric ¶
IsNumeric Checks if the string contains only digits. A decimal point is not a digit and returns false.
func MustReverse ¶
MustReverse reverses a string, panics when error happens.
func PadCenterChar ¶
PadCenterChar center pad a string with a specified character in a larger string(specified size). if the size is less than the param string, the param string is returned. note: size is unicode size.
func PadCenterSpace ¶
PadCenterSpace center pad a string with space character(' ') in a larger string(specified size). if the size is less than the param string, the param string is returned. note: size is unicode size.
func PadLeftChar ¶
PadLeftChar left pad a string with a specified character in a larger string (specified size). if the size is less than the param string, the param string is returned. note: size is unicode size.
func PadLeftSpace ¶
PadLeftSpace left pad a string with space character(' ') in a larger string(specified size). if the size is less than the param string, the param string is returned. note: size is unicode size.
func PadRightChar ¶
PadRightChar right pad a string with a specified character in a larger string(specified size). if the size is less than the param string, the param string is returned. note: size is unicode size.
func PadRightSpace ¶
PadRightSpace right pad a string with space character(' ') in a large string(specified size). if the size is less than the param string, the param string is returned. note: size is unicode size.
func RemoveChar ¶
RemoveChar removes all occurrences of a specified character from the string.
func RemoveString ¶
RemoveString removes all occurrences of a substring from the string.
func RepeatChar ¶
RepeatChar returns padding using the specified delimiter repeated to a given length.
Types ¶
This section is empty.