strings

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 1 Imported by: 1

README

Strings library

Candidate functions :

Func Name Prototype Description Comments
Contains Contains(str string, substr string) bool {} Returns true if the string contains the substring N/A
ContainsAny ContainsAny(str string, chars string) bool {} Returns true if the string contains any of the characters N/A
Count Count(str string, substr string) int {} Returns the number of non-overlapping instances of substr in str N/A
Cut Cut(str string, sep string) before string, after string, found bool {} Returns a string before and after the separator, and a bool if it's found or not N/A
HasPrefix HasPrefix(str string, prefix string) bool {} Returns true if the string starts by the prefix N/A
HasSuffix HasSuffix(str string, suffix string) bool {} Returns true if the string ends by the suffix N/A
IndexOf IndexOf(str string, substr string) int {} Returns the index of the first instance of substr in str, or -1 if not found N/A
Join Join(elems []string, sep string) string {} Returns a concatenated string from an array of string separated by sep N/A
Replace Replace(str string, old string, new string, nb int) string {} Returns a string with the first instance of old replaced by new N/A
ReplaceAll ReplaceAll(str string, old string, new string) string {} Returns a string with all instances of old replaced by new N/A
Split Split(str string, sep string) []string {} Returns an array of the substrings between the separator, or an array only containing str if it doesn't contains sep N/A
SplitAfter SplitAfter(str string, sep string) []string {} Returns an array of the substrings after the separator, or an array only containing str if it doesn't contains sep N/A
SplitAfterN SplitAfterN(str string, sep string, nb int) []string {} Returns an array of the substrings after the separator, or an array only containing str if it doesn't contains sep. The count determines the number of substrings to return N/A
SplitN SplitN(str string, sep string, nb int) []string {} Returns an array of the substrings between the separator, or an array only containing str if it doesn't contains sep. The count determines the number of substrings to return N/A
ToLower ToLower(str string) string {} Returns a string with all characters in lowercase N/A
ToUpper ToUpper(str string) string {} Returns a string with all characters in uppercase N/A
Trim Trim(str string, cutset string) string {} Returns a string with all cut characters removed N/A

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(str string, substr string) bool

Contains returns true if the string contains the substring

func ContainsAny

func ContainsAny(str string, substr string) bool

ContainsAny returns true if the string contains any characters in the substring

func Count

func Count(str string, substr string) int

Count returns the number of times the substring appears in the string

func Cut

func Cut(str string, substr string) (string, string, bool)

Cut returns the strings before and after the substring, and a boolean indicating if the substring was found

func HasPrefix

func HasPrefix(str string, substr string) bool

HasPrefix returns true if the string starts with the prefix

func HasSuffix

func HasSuffix(str string, substr string) bool

HasSuffix returns true if the string ends with the suffix

func IndexOf

func IndexOf(str string, substr string) int

IndexOf returns the index of the first instance of the substring in the string, or -1 if not found

func Join

func Join(elems []string, sep string) string

Join concatenates the strings in the slice with the separator

func Replace

func Replace(str string, old string, new string, nb int) string

Replace returns a copy of the string with old replaced by new and the number of replacements

func ReplaceAll

func ReplaceAll(str string, old string, new string) string

ReplaceAll returns a copy of the string with old replaced by new

func Split

func Split(str string, sep string) []string

Split returns a slice of strings split by the separator

func SplitAfter

func SplitAfter(str string, sep string) []string

SplitAfter returns a slice of strings split after the separator, with the separator included

func SplitAfterN

func SplitAfterN(str string, sep string, n int) []string

SplitAfterN returns a slice of strings split after the separator, with the separator included, with a maximum of n splits

func SplitN

func SplitN(str string, sep string, n int) []string

SplitN returns a slice of strings split by the separator, with a maximum of n splits

func ToLower

func ToLower(str string) string

ToLower returns a copy of the string with all characters converted to lowercase

func ToUpper

func ToUpper(str string) string

ToUpper returns a copy of the string with all characters converted to uppercase

func Trim

func Trim(str string, cutset string) string

Trim returns a copy of the string with all leading and trailing characters in cutset removed

Types

This section is empty.

Jump to

Keyboard shortcuts

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