stringsutil

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 5 Imported by: 0

README

stringsutil

The package contains various helpers to interact with strings

Documentation

Index

Constants

This section is empty.

Variables

Functions

func After

func After(value string, a string) (string, error)

After extracts the string after a from value returns value as is and error if a is not found

func Before

func Before(value string, a string) (string, error)

Before extracts the string before a from value returns value as is and error if a is not found

func Between

func Between(value string, a string, b string) (string, error)

Between extracts the string between a and b returns value as is and error if a or b are not found

func ContainsAny

func ContainsAny(s string, ss ...string) bool

ContainsAny returns true is s contains any specified substring

func EqualFoldAny

func EqualFoldAny(s string, ss ...string) bool

EqualFoldAny returns true if s is equal to any specified substring

func HasPrefixAny

func HasPrefixAny(s string, prefixes ...string) bool

HasPrefixAny checks if the string starts with any specified prefix

func HasPrefixI

func HasPrefixI(s, prefix string) bool

HasPrefixI is case insensitive HasPrefix

func HasSuffixAny

func HasSuffixAny(s string, suffixes ...string) bool

HasSuffixAny checks if the string ends with any specified suffix

func HasSuffixI

func HasSuffixI(s, suffix string) bool

HasSuffixI is case insensitive HasSuffix

func IndexAt

func IndexAt(s, sep string, n int) int

IndexAt look for a substring starting at position x

func Join

func Join(elems []interface{}, sep string) string

Join concatenates the elements of its first argument to create a single string. The separator string sep is placed between elements in the resulting string.

func Normalize

func Normalize(data string) string

func NormalizeWithOptions

func NormalizeWithOptions(data string, options NormalizeOptions) string

func ReplaceAll

func ReplaceAll(s, new string, olds ...string) string

ReplaceAll returns a copy of the string s with all instances of old incrementally replaced by new.

func Reverse

func Reverse(s string) string

Reverse the string

func SlideWithLength

func SlideWithLength(s string, l int) chan string

SlideWithLength returns all the strings of the specified length while moving forward the extraction window

func SplitAny

func SplitAny(s string, seps ...string) []string

SplitAny string by a list of separators

func TrimPrefixAny

func TrimPrefixAny(s string, prefixes ...string) string

TrimPrefixAny trims all prefixes from string in order

func TrimSuffixAny

func TrimSuffixAny(s string, suffixes ...string) string

TrimSuffixAny trims all suffixes from string in order

func Truncate

func Truncate(data string, maxSize int) string

Truncate a string to max length

Types

type EncodingType

type EncodingType uint8
const (
	Unknown EncodingType = iota
	UTF8
	UTF16BE
	UTF16LE
	UTF32BE
	UTF32LE
	ISO85591
	ISO88592
	ISO88595
	ISO88596
	ISO88597
	ISO88598
	Windows1251
	Windows1256
	KOI8R
	ShiftJIS
	GB18030
	EUCJP
	EUCKR
	Big5
	ISO2022JP
	ISO2022KR
	ISO2022CN
	IBM424rtl
	IBM424ltr
	IBM420rtl
	IBM420ltr
)

func DetectEncodingType

func DetectEncodingType(data interface{}) (EncodingType, error)

type LongestSequence

type LongestSequence struct {
	Sequence string
	Count    int
}

func LongestRepeatingSequence

func LongestRepeatingSequence(s string) LongestSequence

LongestRepeatingSequence finds the longest repeating non-overlapping sequence in a string

type NormalizeOptions

type NormalizeOptions struct {
	TrimSpaces bool
	StripHTML  bool
	Lowercase  bool
	Uppercase  bool
}
var DefaultNormalizeOptions NormalizeOptions = NormalizeOptions{
	TrimSpaces: true,
	StripHTML:  true,
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL