strings

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abbreviate

func Abbreviate(s, abbreviateMarker string, offset, maxWidth int) string

Abbreviate is used to abbreviate the given string with the given replacement character. An abbreviation is a shortened form of a word or phrase.

func AbbreviateMiddle

func AbbreviateMiddle(s, middle string, length int) string

AbbreviateMiddle is used to abbreviate a string to the passed length by replacing the middle characters with the supplied replacement string.

The method works only if the following conditions are met. The length of the supplied string should be greater than the length of the abbreviated string. The length of the abbreviated string should be greater than zero.

func AppendIfMissing

func AppendIfMissing(s, suffix string, suffixes ...string) string

AppendIfMissing is used to append a given suffix at the end of a string if it does not already end with one on the given list.

func AppendIfMissingIgnoreCase

func AppendIfMissingIgnoreCase(s, suffix string, suffixes ...string) string

AppendIfMissingIgnoreCase is used to append a given suffix at the end of a string if it does not already end with one on the given list ignoring case.

func Capitalize

func Capitalize(s string) string

Capitalize used to convert the first character of the given string to upper case. The remaining characters of the string are not changed.

func Center

func Center(s string, size int, padCharacter uint8) string

Center centers a string in a larger string of given size padding around the given string the given pad character.

func CenterString

func CenterString(s string, size int, padString string) string

CenterString centers a string in a larger string of given size padding around the given string the given pad string.

func Chomp

func Chomp(s string) string

Chomp is used to remove the last occurring newline character in a given string. If the string ends with multiple newline characters, then only the last occurring newline character is removed. The newline characters are \r, \n or \r\n.

func Chop

func Chop(s string) string

Chop is used to remove the last character and the second last character if it's newline.

func Compare

func Compare(a, b string) int

Compare returns an integer comparing two strings lexicographically. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.h

func CompareIgnoreCase

func CompareIgnoreCase(a, b string) int

CompareIgnoreCase returns an integer comparing two strings ignoring case lexicographically. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.

func Contains

func Contains(s string, searchChar uint8) bool

Contains is used to check if the character is present in the string or not

func ContainsAny

func ContainsAny(s string, searchChars ...uint8) bool

ContainsAny is used to check if any of the characters is present in the string or not

func ContainsAnyIgnoreCase

func ContainsAnyIgnoreCase(s string, searchChars ...uint8) bool

ContainsAnyIgnoreCase is used to check if any of the characters is present in the string or not ignoring case

func ContainsIgnoreCase

func ContainsIgnoreCase(s string, searchChar uint8) bool

ContainsIgnoreCase is used to check if the character is present in the string or not ignoring case

func ContainsNone

func ContainsNone(s string, searchChars ...uint8) bool

ContainsNone is used to check if none of the characters is present in the string or not

func ContainsNoneIgnoreCase

func ContainsNoneIgnoreCase(s string, searchChars ...uint8) bool

ContainsNoneIgnoreCase is used to check if none of the characters is present in the string or not ignoring case

func ContainsOnly

func ContainsOnly(s string, validChars ...uint8) bool

ContainsOnly is used to check if the strings contains only the given valid characters

func ContainsOnlyIgnoreCase

func ContainsOnlyIgnoreCase(s string, validChars ...uint8) bool

ContainsOnlyIgnoreCase is used to check if the strings contains only the given valid characters ignoring case

func ContainsString

func ContainsString(s, search string) bool

ContainsString is used to check if the string is present in the given string or not

func ContainsStringIgnoreCase

func ContainsStringIgnoreCase(s, search string) bool

ContainsStringIgnoreCase is used to check if the string is present in the string or not ignoring case

func ContainsWhitespace

func ContainsWhitespace(s string) bool

ContainsWhitespace is used to check if the string contains whitespace

func Count

func Count(s string, ch uint8) int

Count is used to count the number of occurrences of a character or a substring in a larger string/text. Here, character or substring matching is case-sensitive in nature.

func CountIgnoreCase

func CountIgnoreCase(s string, ch uint8) int

CountIgnoreCase is used to count the number of occurrences of a character or a substring in a larger string/text. Here, character or substring matching is not case-sensitive in nature.

func DefaultIfBlank

func DefaultIfBlank(s, df string) string

DefaultIfBlank takes 2 parameters a string and a default string. If the passed string is blank, then it returns the default string otherwise it returns the passed string.

A string is considered to be blank if it satisfied one of the criteria below. Length of string is 0. String contains only whitespace characters.

func DefaultIfEmpty

func DefaultIfEmpty(s, df string) string

DefaultIfEmpty takes 2 parameters a string and a default string. If the passed string is empty, then it returns the default string otherwise it returns the passed string.

func DeleteWhitespaces

func DeleteWhitespaces(s string) string

DeleteWhitespaces removes all the whitespace characters in a given string.

func Difference

func Difference(a, b string) string

Difference is used to compare two strings and return the remaining characters of the second string that differ from the first string.

func EndsWith

func EndsWith(s, suffix string) bool

EndsWith checks whether the given string ends with the given string/suffix. This method is case-sensitive when comparing the suffix with the end of the string.

func EndsWithAny

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

EndsWithAny checks whether the given string ends with the given any of the given strings/suffixes. This method is case-sensitive when comparing the suffix with the end of the string.

func EndsWithAnyIgnoreCase

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

EndsWithAnyIgnoreCase checks whether the given string ends with the given any of the given strings/suffixes. This method is case-insensitive when comparing the suffix with the end of the string.

func EndsWithIgnoreCase

func EndsWithIgnoreCase(s, suffix string) bool

EndsWithIgnoreCase checks if the given string ends with the given string/suffix. This method is case-insensitive when comparing the suffix with the end of the string.

func Equals

func Equals(a, b string) bool

Equals is used to check if the 2 strings are equal or not.

func EqualsAny

func EqualsAny(a string, bb ...string) bool

EqualsAny is used to check if a string is equal to any of the given strings or not

func EqualsAnyIgnoreCase

func EqualsAnyIgnoreCase(a string, bb ...string) bool

EqualsAnyIgnoreCase is used to check if a string is equal to any of the given strings or not ignoring case.

func EqualsIgnoreCase

func EqualsIgnoreCase(a, b string) bool

EqualsIgnoreCase is used to check if the 2 strings are equal or not ignoring case.

func FirstNonBlank

func FirstNonBlank(ss ...string) string

FirstNonBlank returns the first element in the given list of elements that is not empty, null, or whitespace only. If all the elements are blank or the list is null or empty, null is returned.

func FirstNonEmpty

func FirstNonEmpty(ss ...string) string

FirstNonEmpty returns the first element in a given list of elements that is not empty. If all the elements are null or empty then null is returned.

func GetCommonPrefix

func GetCommonPrefix(ss ...string) string

GetCommonPrefix compares all strings in an array of strings and returns the common starting character sequence that all of them share.

func GetDigits

func GetDigits(s string) string

GetDigits checks for Unicode digits in a string and returns a new string that contains all the digits in the given string. If the given string does not contain any digits, an empty string will be returned.

func GetIfBlank

func GetIfBlank(ctx context.Context, s string, supplier func(ctx context.Context) string) string

GetIfBlank is used to call the function and get the data if the provided string is blank.

A string is considered to be blank if it satisfied one of the criteria below. Length of string is 0. String contains only whitespace characters.

func GetIfEmpty

func GetIfEmpty(ctx context.Context, s string, supplier func(ctx context.Context) string) string

GetIfEmpty is used to call the function and get the data if the provided string is empty.

func HashCode added in v0.2.0

func HashCode(s string) int32

HashCode is used to compute the hash values for the given string.

func IndexOf

func IndexOf(s string, search uint8) int

IndexOf is used to get the index of the first occurrence of the given character. If the character is not found, then it will return -1.

func IndexOfAny

func IndexOfAny(s string, searchChars ...uint8) int

IndexOfAny is used to get the index of the first occurrence of one of the given characters. If the character is not found, then it will return -1.

func IndexOfAnyBut

func IndexOfAnyBut(s string, searchChars ...uint8) int

IndexOfAnyBut is used to get the index of the first occurrence of any character other than one of the given characters. If the character is not found, then it will return -1.

func IndexOfAnyButIgnoreCase

func IndexOfAnyButIgnoreCase(s string, searchChars ...uint8) int

IndexOfAnyButIgnoreCase is used to get the index of the first occurrence of any character other than one of the given characters ignoring case. If the character is not found, then it will return -1.

func IndexOfAnyIgnoreCase

func IndexOfAnyIgnoreCase(s string, searchChars ...uint8) int

IndexOfAnyIgnoreCase is used to get the index of the first occurrence of one of the given characters ignoring case. If the character is not found, then it will return -1.

func IndexOfDifference

func IndexOfDifference(ss ...string) int

IndexOfDifference figures out the index of the first character sequence that differs from the given sequence. The comparison of the character sequences in the given text is case-sensitive.

func IndexOfIgnoreCase

func IndexOfIgnoreCase(s string, search uint8) int

IndexOfIgnoreCase is used to get the index of the first occurrence of the given character ignoring case. If the character is not found, then it will return -1.

func IndexOfString

func IndexOfString(s, search string) int

IndexOfString is used to get the index of the first occurrence of the given string. If the character is not found, then it will return -1.

func IndexOfStringIgnoreCase

func IndexOfStringIgnoreCase(s, search string) int

IndexOfStringIgnoreCase is used to get the index of the first occurrence of the given string ignoring case. If the string is not found, then it will return -1.

func IndexOfStringStartingAt

func IndexOfStringStartingAt(s, search string, start int) int

IndexOfStringStartingAt is used to get the index of the first occurrence of the given string starting with index provided. If the character is not found, then it will return -1.

func IsAllBlank

func IsAllBlank(ss ...string) bool

IsAllBlank is used to check if the all the given strings are blank.

A string is considered to be blank if it satisfied one of the criteria below. Length of string is 0. String contains only whitespace characters.

func IsAllEmpty

func IsAllEmpty(ss ...string) bool

IsAllEmpty is used to check if the all the given strings are empty.

func IsAllLowerCase

func IsAllLowerCase(ss ...string) bool

IsAllLowerCase is used to check if all characters in the all the given strings is in lower case.

func IsAllMixedCase

func IsAllMixedCase(ss ...string) bool

IsAllMixedCase is used to check if all the given strings contain both upper and lower case characters.

func IsAllUpperCase

func IsAllUpperCase(ss ...string) bool

IsAllUpperCase is used to check if all characters in the all the given strings is in upper case.

func IsAlpha

func IsAlpha(s string) bool

IsAlpha checks whether a given string contains only letters. The function returns false if the input string is empty.

func IsAlphaNumeric

func IsAlphaNumeric(s string) bool

IsAlphaNumeric checks whether a given string contains only letters or digits. The function returns false if the input string is empty.

func IsAlphaNumericSpace

func IsAlphaNumericSpace(s string) bool

IsAlphaNumericSpace checks whether a given string contains only letters or digits or space. The function returns false if the input string is empty.

func IsAlphaSpace

func IsAlphaSpace(s string) bool

IsAlphaSpace checks whether a given string contains only letters or space. The function returns false if the input string is empty.

func IsAnyBlank

func IsAnyBlank(ss ...string) bool

IsAnyBlank is used to check if any of the given strings is blank or not.

A string is considered to be blank if it satisfied one of the criteria below. Length of string is 0. String contains only whitespace characters.

func IsAnyEmpty

func IsAnyEmpty(ss ...string) bool

IsAnyEmpty is used to check if any of the given strings is empty or not.

func IsAnyLowerCase

func IsAnyLowerCase(ss ...string) bool

IsAnyLowerCase is used to check if all characters in any of the given strings is in lower case.

func IsAnyMixedCase

func IsAnyMixedCase(ss ...string) bool

IsAnyMixedCase is used to check if any of the given strings contain both upper and lower case characters.

func IsAnyUpperCase

func IsAnyUpperCase(ss ...string) bool

IsAnyUpperCase is used to check if all characters in any of the given strings is in upper case.

func IsAsciiPrintable

func IsAsciiPrintable(s string) bool

IsAsciiPrintable is used to check if the given string contains only ASCII characters that are printable.

func IsBlank

func IsBlank(s string) bool

IsBlank is used to check if the given string is blank.

A string is considered to be blank if it satisfied one of the criteria below. Length of string is 0. String contains only whitespace characters.

func IsEmpty

func IsEmpty(s string) bool

IsEmpty is used to check if a given string is empty or not.

func IsLowerCase

func IsLowerCase(s string) bool

IsLowerCase is used to check if all characters in the string is in lower case.

func IsMixedCase

func IsMixedCase(s string) bool

IsMixedCase is used to check if it contains both upper and lower case characters.

func IsNoneBlank

func IsNoneBlank(ss ...string) bool

IsNoneBlank is used to check if none of the given strings are blank.

A string is considered to be blank if it satisfied one of the criteria below. Length of string is 0. String contains only whitespace characters.

func IsNoneEmpty

func IsNoneEmpty(ss ...string) bool

IsNoneEmpty is used to check if none of the given strings are empty.

func IsNumeric

func IsNumeric(s string) bool

IsNumeric checks whether a given string contains only digits. The function returns false if the input string is empty.

func IsNumericSpace

func IsNumericSpace(s string) bool

IsNumericSpace checks whether a given string contains only digits or space. The function returns false if the input string is empty.

func IsUpperCase

func IsUpperCase(s string) bool

IsUpperCase is used to check if all characters in the string is in upper case.

func JoinByChar

func JoinByChar(cc []uint8, d uint8) string

JoinByChar is used to join the characters by a character.

func JoinStringersByChar added in v0.6.1

func JoinStringersByChar[K any](ss []K, d uint8, stringer func(a K) string) string

JoinStringersByChar is used to join the values converting them to string by stringer by a character.

func JoinStringersByString added in v0.6.1

func JoinStringersByString[K any](ss []K, ds string, stringer func(a K) string) string

JoinStringersByString is used to join the values converting them to string by stringer by a string.

func JoinStringsByChar

func JoinStringsByChar(ss []string, d uint8) string

JoinStringsByChar is used to join the strings by a character.

func JoinStringsByString

func JoinStringsByString(ss []string, ds string) string

JoinStringsByString is used to join the strings by a string.

func LastIndexOf

func LastIndexOf(s string, search uint8) int

LastIndexOf is used to get the index of the first occurrence of the given character. If the character is not found, then it will return -1.

func LastIndexOfAny

func LastIndexOfAny(s string, searchChars ...uint8) int

LastIndexOfAny is used to get the index of the first occurrence of one of the given characters. If the character is not found, then it will return -1.

func LastIndexOfAnyBut

func LastIndexOfAnyBut(s string, searchChars ...uint8) int

LastIndexOfAnyBut is used to get the index of the first occurrence of any character other than one of the given characters. If the character is not found, then it will return -1.

func LastIndexOfAnyButIgnoreCase

func LastIndexOfAnyButIgnoreCase(s string, searchChars ...uint8) int

LastIndexOfAnyButIgnoreCase is used to get the index of the first occurrence of any character other than one of the given characters ignoring case. If the character is not found, then it will return -1.

func LastIndexOfAnyIgnoreCase

func LastIndexOfAnyIgnoreCase(s string, searchChars ...uint8) int

LastIndexOfAnyIgnoreCase is used to get the index of the first occurrence of one of the given characters ignoring case. If the character is not found, then it will return -1.

func LastIndexOfIgnoreCase

func LastIndexOfIgnoreCase(s string, search uint8) int

LastIndexOfIgnoreCase is used to get the index of the first occurrence of the given character ignoring case. If the character is not found, then it will return -1.

func LastIndexOfString

func LastIndexOfString(s, search string) int

LastIndexOfString is used to get the index of the first occurrence of the given string. If the character is not found, then it will return -1.

func LastIndexOfStringIgnoreCase

func LastIndexOfStringIgnoreCase(s, search string) int

LastIndexOfStringIgnoreCase is used to get the index of the first occurrence of the given string ignoring case. If the string is not found, then it will return -1.

func Left

func Left(s string, l int) string

Left is used to get the specified number of leftmost characters of a string.

func LeftPad

func LeftPad(s string, size int, padCharacter uint8) string

LeftPad is used to left pad the given character to the given string.

func LeftPadString

func LeftPadString(s string, size int, padString string) string

LeftPadString is used to left pad the given string to the given string.

func LowerCase

func LowerCase(s string) string

LowerCase is used to convert a string to lower case.

func Mid

func Mid(s string, pos, length int) string

Mid is used to return the string starting from the given position index upto the given length.

func NormalizeSpace

func NormalizeSpace(s string) string

NormalizeSpace is used to return the whitespace normalized string by removing the leading and trailing whitespace and then replacing sequences of whitespace characters with a single space.

func OrdinalIndexOf

func OrdinalIndexOf(s, search string, ordinal int) int

OrdinalIndexOf is used to return the index of the nth occurrence of the search string in the given string

func Overlay

func Overlay(s, overlay string, start, end int) string

Overlay overlays part of a String with another String. A negative index is treated as zero. An index greater than the string length is treated as the string length. The start index is always the smaller of the two indices.

func PrependIfMissing

func PrependIfMissing(s, prefix string, prefixes ...string) string

PrependIfMissing is used to prepend a given prefix at the start of a string if it does not already start with one on the given list.

func PrependIfMissingIgnoreCase

func PrependIfMissingIgnoreCase(s, prefix string, prefixes ...string) string

PrependIfMissingIgnoreCase is used to prepend a given prefix at the start of a string if it does not already start with one on the given list ignoring case.

func Remove

func Remove(s string, remove uint8) string

Remove is used to remove all occurrences of a given character in the string

func RemoveEnd

func RemoveEnd(s, remove string) string

RemoveEnd is used to remove the occurrence of the given string from the given string's end

func RemoveEndIgnoreCase

func RemoveEndIgnoreCase(s, remove string) string

RemoveEndIgnoreCase is used to remove the occurrence of the given string from the given string's end ignoring case

func RemoveIgnoreCase

func RemoveIgnoreCase(s string, remove uint8) string

RemoveIgnoreCase is used to remove all occurrences of a given character in the string ignoring case

func RemoveStart

func RemoveStart(s, remove string) string

RemoveStart is used to remove the occurrence of the given string from the given string's start

func RemoveStartIgnoreCase

func RemoveStartIgnoreCase(s, remove string) string

RemoveStartIgnoreCase is used to remove the occurrence of the given string's start from the given string ignoring case

func RemoveString

func RemoveString(s, remove string) string

RemoveString is used to remove all occurrences of a given string in the string

func RemoveStringIgnoreCase

func RemoveStringIgnoreCase(s, remove string) string

RemoveStringIgnoreCase is used to remove all occurrences of a given string in the string ignoring case

func Repeat

func Repeat(c uint8, repeat int) string

Repeat is used to repeat the given character the given number of times.

func RepeatString

func RepeatString(s string, repeat int) string

RepeatString is used to repeat the given string the given number of times.

func RepeatStringWithSeparator

func RepeatStringWithSeparator(s, separator string, repeat int) string

RepeatStringWithSeparator is used to repeat the given string the given number of times each separated by the given separator.

func Replace

func Replace(s, search, replacement string, max int) string

Replace is used to replace the given number of occurrences of a string in the given string with another string.

func ReplaceAll

func ReplaceAll(s, search, replacement string) string

ReplaceAll is used to replace all occurrences of a string in the given string with another string.

func ReplaceEach

func ReplaceEach(s string, searchList, replacementList []string) string

ReplaceEach is used to replace each of the characters in the search list with the corresponding character in the replacement list exactly once.

func ReplaceIgnoreCase

func ReplaceIgnoreCase(s, search, replacement string, max int) string

ReplaceIgnoreCase is used to replace the given number of occurrences of a string in the given string with another string ignoring case.

func Reverse

func Reverse(s string) string

Reverse is used to reverse the given string

func ReverseDelimited

func ReverseDelimited(s string, d uint8) string

ReverseDelimited is used to reverse the given string split by the delimiter

func Right(s string, l int) string

Right is used to get the specified number of rightmost characters of a string.

func RightPad

func RightPad(s string, size int, padCharacter uint8) string

RightPad is used to right pad the given character to the given string.

func RightPadString

func RightPadString(s string, size int, padString string) string

RightPadString is used to right pad the given string to the given string.

func Rotate

func Rotate(s string, shift int) string

Rotate is used to rotate the string by given number of characters

func Split

func Split(s string, separator uint8) []string

Split is used to split the string into a list of strings about the separator provided

func SplitByString

func SplitByString(s, separator string) []string

SplitByString is used to split the string by the separator provided

func SplitByStringWithTrim

func SplitByStringWithTrim(s, separator string) []string

SplitByStringWithTrim is used to split the string by the separator provided and trim the splits

func SplitByStringWithTrimCutSet

func SplitByStringWithTrimCutSet(s, separator string, set string) []string

SplitByStringWithTrimCutSet is used to split the string by the separator provided and trailing Unicode code points contained in cut set removed.

func SplitN

func SplitN(s string, separator uint8, n int) []string

SplitN slices s into substrings separated by sep and returns a slice of the substrings between those separators.

The count determines the number of substrings to return:

n > 0: at most n substrings; the last substring will be the remainder which won't be split.
n == 0: the result is nil (zero substrings)
n < 0: all substrings

Edge cases for s and sep (for example, empty strings) are handled as described in the documentation for Split.

func SplitNByString

func SplitNByString(s, separator string, n int) []string

SplitNByString slices s into substrings separated by sep and returns a slice of the substrings between those separators.

The count determines the number of substrings to return:

n > 0: at most n substrings; the last substring will be the remainder which won't be split.
n == 0: the result is nil (zero substrings)
n < 0: all substrings

Edge cases for s and sep (for example, empty strings) are handled as described in the documentation for Split.

func SplitNByStringWithTrim

func SplitNByStringWithTrim(s, separator string, n int) []string

SplitNByStringWithTrim slices s into substrings separated by sep and returns a slice of the substrings between those separators and along with that trim the splits.

The count determines the number of substrings to return:

n > 0: at most n substrings; the last substring will be the remainder which won't be split.
n == 0: the result is nil (zero substrings)
n < 0: all substrings

Edge cases for s and sep (for example, empty strings) are handled as described in the documentation for Split.

func SplitNByStringWithTrimCutSet

func SplitNByStringWithTrimCutSet(s, separator string, n int, set string) []string

SplitNByStringWithTrimCutSet slices s into substrings separated by sep and returns a slice of the substrings between those separators and trailing Unicode code points contained in cut set removed.

The count determines the number of substrings to return:

n > 0: at most n substrings; the last substring will be the remainder which won't be split.
n == 0: the result is nil (zero substrings)
n < 0: all substrings

Edge cases for s and sep (for example, empty strings) are handled as described in the documentation for Split.

func SplitNWithTrim

func SplitNWithTrim(s string, separator uint8, n int) []string

SplitNWithTrim slices s into substrings separated by sep and returns a slice of the substrings between those separators and along with that trim the splits.

The count determines the number of substrings to return:

n > 0: at most n substrings; the last substring will be the remainder which won't be split.
n == 0: the result is nil (zero substrings)
n < 0: all substrings

Edge cases for s and sep (for example, empty strings) are handled as described in the documentation for Split.

func SplitNWithTrimCutSet

func SplitNWithTrimCutSet(s string, separator uint8, n int, set string) []string

SplitNWithTrimCutSet slices s into substrings separated by sep and returns a slice of the substrings between those separators and trailing Unicode code points contained in cut set removed.

The count determines the number of substrings to return:

n > 0: at most n substrings; the last substring will be the remainder which won't be split.
n == 0: the result is nil (zero substrings)
n < 0: all substrings

Edge cases for s and sep (for example, empty strings) are handled as described in the documentation for Split.

func SplitWithTrim

func SplitWithTrim(s string, separator uint8) []string

SplitWithTrim is used to split and trim the splits

func SplitWithTrimCutSet

func SplitWithTrimCutSet(s string, separator uint8, set string) []string

SplitWithTrimCutSet is used to split and trailing Unicode code points contained in cut set removed.

func StartsWith

func StartsWith(s, prefix string) bool

StartsWith is used to check if the provided prefix is present at the beginning of the string or not.

func StartsWithAny

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

StartsWithAny is used to check if any of the provided prefixes is present at the beginning of the string or not.

func StartsWithAnyIgnoreCase

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

StartsWithAnyIgnoreCase is used to check if any of the provided prefixes is present at the beginning of the string or not ignoring case.

func StartsWithIgnoreCase

func StartsWithIgnoreCase(s, prefix string) bool

StartsWithIgnoreCase is used to check if the provided prefix is present at the beginning of the string or not ignoring case.

func Strip

func Strip(s, cc string) string

Strip is used to remove the given set of characters from the starting and ending of the string

func StripAll

func StripAll(ss []string, cc string) []string

StripAll is used to remove the given set of characters from the starting and ending of the given list of strings

func StripAllEnd

func StripAllEnd(ss []string, cc string) []string

StripAllEnd is used to remove the given set of characters from the ending of the given list of strings

func StripAllStart

func StripAllStart(ss []string, cc string) []string

StripAllStart is used to remove the given set of characters from the starting of the given list of strings

func StripEnd

func StripEnd(s, cc string) string

StripEnd is used to remove the given set of characters from the ending of the string

func StripStart

func StripStart(s, cc string) string

StripStart is used to remove the given set of characters from the starting of the string

func Substring

func Substring(s string, start, end int) string

Substring returns the string between the given start(inclusive) and the end(exclusive) index.

func SubstringAfter

func SubstringAfter(s string, separator uint8) string

SubstringAfter returns the string after the first occurrence of the separator in the string.

func SubstringAfterLast

func SubstringAfterLast(s string, separator uint8) string

SubstringAfterLast returns the string after the last occurrence of the separator in the string.

func SubstringAfterLastString

func SubstringAfterLastString(s, separator string) string

SubstringAfterLastString returns the string after the last occurrence of the separator in the string.

func SubstringAfterString

func SubstringAfterString(s, separator string) string

SubstringAfterString returns the string after the first occurrence of the separator in the string.

func SubstringBefore

func SubstringBefore(s string, separator uint8) string

SubstringBefore returns the string after the first occurrence of the separator in the string.

func SubstringBeforeLast

func SubstringBeforeLast(s string, separator uint8) string

SubstringBeforeLast returns the string after the last occurrence of the separator in the string.

func SubstringBeforeLastString

func SubstringBeforeLastString(s, separator string) string

SubstringBeforeLastString returns the string after the last occurrence of the separator in the string.

func SubstringBeforeString

func SubstringBeforeString(s, separator string) string

SubstringBeforeString returns the string after the first occurrence of the separator in the string.

func SubstringTillEnd

func SubstringTillEnd(s string, start int) string

SubstringTillEnd returns the string from the given start index till the end of the string.

func SwapCase

func SwapCase(s string) string

SwapCase is used to change the case of lower case characters to upper case and vice-versa.

func ToCodePoints

func ToCodePoints(s string) []int32

ToCodePoints returns the unicode code point for the characters of the string.

func Trim

func Trim(s, cc string) string

Trim returns a slice of the string s with all leading and trailing Unicode code points contained in cut set removed.

func TrimLeft

func TrimLeft(s, cc string) string

TrimLeft returns a slice of the string s with all leading Unicode code points contained in cut set removed.

To remove a prefix, use TrimPrefix instead.

func TrimPrefix

func TrimPrefix(s, prefix string) string

TrimPrefix returns s without the provided leading prefix string. If s doesn't start with prefix, s is returned unchanged.

func TrimRight

func TrimRight(s, cc string) string

TrimRight returns a slice of the string s, with all trailing Unicode code points contained in cut-set removed.

To remove a suffix, use TrimSuffix instead.

func TrimSpace

func TrimSpace(s string) string

TrimSpace returns a slice of the string s, with all leading and trailing white space removed, as defined by Unicode.

func TrimSuffix

func TrimSuffix(s, suffix string) string

TrimSuffix returns s without the provided trailing suffix string. If s doesn't end with suffix, s is returned unchanged.

func Truncate

func Truncate(s string, offset, maxWidth int) string

Truncate is used to return the substring of the string starting from the offset position and having a width <= max width.

func TruncateFromStart

func TruncateFromStart(s string, maxWidth int) string

TruncateFromStart is used to return the substring of the string starting from the beginning and having a width <= max width.

func Uncapitalize

func Uncapitalize(s string) string

Uncapitalize used to convert the first character of the given string to lower case. The remaining characters of the string are not changed.

func UpperCase

func UpperCase(s string) string

UpperCase is used to convert a string to upper case.

Types

This section is empty.

Jump to

Keyboard shortcuts

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