Documentation ¶
Index ¶
- Variables
- func ASCII(s string) string
- func Digest(s string, options ...Option) string
- func Fields(s string, sep string, joiner string, i ...int) string
- func IsANSI(str string) bool
- func IsASCII(str string) bool
- func IsNumber(str string) bool
- func Latin1(s string) string
- func NewTranslator(pattern string) *xstrings.Translator
- func ParseBrackets(s string, lr rune, rr rune, options ...Option) (result [][]int, balanced bool)
- func Split(s string, r rune, options ...Option) []string
- func SubString(s string, i ...int) string
- func TrimSpaceLeft(s string) string
- func TrimSpaceRight(s string) string
- func UnEscape(s string, escapeset string, escape rune) string
- func WithKeepEscape(c *Config)
- func WithNotEscaped(c *Config)
- type Config
- type Option
Constants ¶
This section is empty.
Variables ¶
var ASCIILetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
var ASCIILowercase = "abcdefghijklmnopqrstuvwxyz"
var ASCIIUppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var ASCIIWhitespace = " \t\n\r\x0b\x0c"
var Center = xstrings.Center
var Count = xstrings.Count
var Delete = xstrings.Delete
var Digits = "0123456789"
var ExpandTabs = xstrings.ExpandTabs
var FirstRuneToLower = xstrings.FirstRuneToLower
var FirstRuneToUpper = xstrings.FirstRuneToUpper
var HexDigits = "0123456789abcdefABCDEF"
var Insert = xstrings.Insert
var JustifyLeft = xstrings.LeftJustify
var JustifyRight = xstrings.RightJustify
var Len = xstrings.Len
var LowerLeft = xstrings.FirstRuneToLower
var OctDigits = "01234567"
var Partition = xstrings.Partition
var PartitionLast = xstrings.LastPartition
var Punctuation = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~."
var Reverse = xstrings.Reverse
var RuneWidth = xstrings.RuneWidth
var Scrub = xstrings.Scrub
var Shuffle = xstrings.Shuffle
var ShuffleSource = xstrings.ShuffleSource
var Slice = xstrings.Slice
var Squeeze = xstrings.Squeeze
var Successor = xstrings.Successor
var SwapCase = xstrings.SwapCase
var ToCamelCase = xstrings.ToCamelCase
var ToKebabCase = xstrings.ToKebabCase
var ToSnakeCase = xstrings.ToSnakeCase
var Translate = xstrings.Translate
var TrimSpace = strings.TrimSpace
TrimSpace returns a slice of the string s, with all leading and trailing white space removed, as defined by Unicode.
var UpperLeft = xstrings.FirstRuneToUpper
var ValidUTF8 = utf8.Valid
ValidUTF8 reports whether string consists entirely of valid UTF-8-encoded runes.
var Whitespace = "" /* 156-byte string literal not displayed */
var Width = xstrings.Width
var WordCount = xstrings.WordCount
var WordSplit = xstrings.WordSplit
Functions ¶
func Digest ¶ added in v1.0.0
Digest return a digest of a string It is based on the hexadecimal (lowercase) representation of SHA-512. Specify the option WithMaxLen to shorten the 64 byte representation
func IsANSI ¶
IsANSI returns true if the entire string contains only ANSI characters. On empty string, the function returns true.
func IsASCII ¶
IsASCII returns true if the entire string contains only ASCII characters. On empty string, the function returns true.
func IsNumber ¶
IsNumber returns true if the entire string contains only ASCII digits On empty string, the function returns false
func NewTranslator ¶
func NewTranslator(pattern string) *xstrings.Translator
func ParseBrackets ¶
Options:
WithNotEscaped: `lr` and `rr` are not escaped WithEscapeRune('...'): replace the default escape rune with another rune
Examples:
ParseBrackets("a(b(c))", '(', ')') -> [[1 6] [3 5]], true ParseBrackets("é(b(é))", '(', ')') -> [[2 8] [4 7]], true ParseBrackets("aébécèè", 'é', 'è') -> [[1 9] [4 7]], true ParseBrackets(`(bb\)c\(dd)e`, '(', ')') -> [[1 11]], true ParseBrackets(`Ë(bb\)c\(dd)e`, '(', ')') -> [[2 12]], true ParseBrackets(`Ë(bb\)c\(dd)e`, '(', ')', WithNotEscaped) -> [[2 6], [9, 12]], true
func Split ¶
Split splits a string on a rune to a slice of strings. Options:
WithNotEscaped: true | false (default): indicates if the rune can be escaped to prevent splitting. WithEscapeRune: escape character. Default '\'. The escape character is only special before the rune and the escape character itself. WithKeepEscape: true | false (default): indicates if the escape characters are to be present after splitting
func TrimSpaceLeft ¶ added in v1.0.0
TrimSpaceLeft returns a slice of the string s, with all leading white space removed, whitespace as defined by Unicode.
func TrimSpaceRight ¶ added in v1.0.0
TrimSpaceRight returns a slice of the string s, with all trailing white space removed, whitespace as defined by Unicode.
func UnEscape ¶
UnEscape replaces the escape rune, followed by a rune out of a specific set (escapeset), with the latter. If the only rune in the set is the escape character, it is af every rune belongs to the escapeset. (the escape rune is always added to this set) If the escape character is not followed by any rune (at the end of the string), it is added to the result
Examples:
UnEscape(`a\b`, `b`, '\\') -> `ab` UnEscape(`a\b`, `c`, '\\') -> `a\b` UnEscape(`a\\b`, `c`, '\\') -> `a\b` UnEscape(`ab\`, `c`, '\\') -> `ab\` UnEscape(`ab\\`, `c`, '\\') -> `ab\` UnEscape(`a\\b\\`, `\`, '\\') -> `ab\`
func WithKeepEscape ¶
func WithKeepEscape(c *Config)
func WithNotEscaped ¶
func WithNotEscaped(c *Config)
Types ¶
type Option ¶
type Option func(*Config)