stringutils

package
v0.0.101 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 9 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BOMS = [][]byte{
	{0xef, 0xbb, 0xbf},
	{0xfe, 0xff},
	{0xff, 0xfe},
	{0x00, 0x00, 0xfe, 0xff},
	{0xff, 0xfe, 0x00, 0x00},
}

Functions

func ArrayToMap added in v0.0.74

func ArrayToMap(slice []string) map[string]struct{}

func CheckPalindrome added in v0.0.19

func CheckPalindrome(str string) bool

CheckPalindrome is delegated to verify if the given string is palindrome

func CheckPresence

func CheckPresence(array []string, target string) bool

CheckPresence verify that the given array contains the target string

func ContainsLetter

func ContainsLetter(str string) bool

ContainsLetter verity that the given string contains, at least, an ASCII alphabet characters Note: whitespace is allowed

func ContainsMultiple added in v0.0.28

func ContainsMultiple(lower bool, s string, substring ...string) bool

ContainsMultiple is delegated to verify if the given string 's' contains all the 'substring' present

func ContainsOnlyLetter added in v0.0.12

func ContainsOnlyLetter(str string) bool

ContainsOnlyLetter verity that the given string contains, only, ASCII alphabet characters Note, whitespace is allowed

func Count added in v0.0.83

func Count(data []string, target string) int

func CountLines

func CountLines(str string) int

CountLines return the number of lines in the given string

func CreateJSON

func CreateJSON(values []string) string

CreateJSON is delegated to create a simple json object for the key pair in input

func DiceCoefficient added in v0.0.22

func DiceCoefficient(string1, string2 string) float64

DiceCoefficient is bigram position dependent implementation of the Dice coefficient

func ExtractString

func ExtractString(data *string, first, last string) string

ExtractString is delegated to filter the content of the given data delimited by 'first' and 'last' string

func ExtractTextFromQuery

func ExtractTextFromQuery(target string, ignore []string) []string

ExtractTextFromQuery is delegated to retrieve the list of word involved in the query. It can be viewed as a tokenizer that use whitespace for delimit the word

func ExtractUpperBlock added in v0.0.83

func ExtractUpperBlock(word string, replacer *strings.Replacer) string

func GetFirstRune added in v0.0.41

func GetFirstRune(data string) rune

func HasPrefixArray added in v0.0.51

func HasPrefixArray(prefixs []string, target string) bool

func Indexes added in v0.0.94

func Indexes(s string, chs string) []int

func IsASCII

func IsASCII(s string) bool

IsASCII is delegated to verify if a given string is ASCII compliant

func IsASCIIRune added in v0.0.4

func IsASCIIRune(r rune) bool

IsASCIIRune is delegated to verify if the given character is ASCII compliant

func IsBlank added in v0.0.6

func IsBlank(str string) bool

IsBlank is delegated to verify that the string does not contain only empty char

func IsLower added in v0.0.2

func IsLower(str string) bool

IsLower verify that a string contains only lower character

func IsUpper

func IsUpper(str string) bool

IsUpper verify that a string contains only upper character

func JaroDistance added in v0.0.22

func JaroDistance(str1, str2 string) float64

JaroDistance is delegated to calculate the Jaro distance from the two given string

func Join

func Join(strs ...string) string

Join is a quite efficient string "concatenator"

func JoinSeparator added in v0.0.28

func JoinSeparator(sep string, strs ...string) string

JoinSeparator is a quite efficient string "concatenator"

func LevenshteinDistance added in v0.0.22

func LevenshteinDistance(str1, str2 string) int

LevenshteinDistance is an optimized version for calculate the levenstein distance

func LevenshteinDistanceLegacy added in v0.0.22

func LevenshteinDistanceLegacy(str1, str2 string) int

LevenshteinDistanceLegacy is delegated to calculate the Levenshtein distance for the given string

func Pad added in v0.0.101

func Pad(w, v string, n int) string

func RemoveDoubleWhiteSpace added in v0.0.19

func RemoveDoubleWhiteSpace(str string) string

RemoveDoubleWhiteSpace is delegated to remove the whitespace from the given string FIXME: memory inefficient, use 2n size, use RemoveFromString method instead

func RemoveFromString

func RemoveFromString(data string, i int) string

RemoveFromString Remove a given character in position i from the input string

func RemoveNonASCII added in v0.0.5

func RemoveNonASCII(str string) string

RemoveNonASCII is delegated to clean the text from the NON ASCII character

func RemoveWhiteSpace added in v0.0.19

func RemoveWhiteSpace(str string) string

RemoveWhiteSpace is delegated to remove the whitespace from the given string FIXME: memory inefficient, use 2n size, use RemoveFromString method instead

func ReplaceAtIndex added in v0.0.3

func ReplaceAtIndex(str, replacement string, index int) string

ReplaceAtIndex is delegated to replace the character related to the index with the input rune

func ReverseString added in v0.0.19

func ReverseString(str string) string

ReverseString is delegated to return the reverse of the input string

func Split

func Split(data io.Reader) []string

Split is delegated to split the string by the new line

func Trim added in v0.0.6

func Trim(str string) string

Trim is delegated to remove the initial, final whitespace and the double whitespace present in the data It also converts every new line in a space

func TrimStrings added in v0.0.101

func TrimStrings(vs []string) []string

Types

This section is empty.

Jump to

Keyboard shortcuts

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