gostr

package module
v0.0.0-...-e0263ef Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2017 License: MIT Imports: 3 Imported by: 0

README

gostr

Useful strings utilities for GO, heavily inspried by Stringy and strman.

Install

go get github.com/sijad/gostr

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(strs ...string) string

Append appends given strings strs.

func AppendArray

func AppendArray(s string, strs []string) string

AppendArray appends an array of strings to the string s.

func At

func At(s string, index int) string

At returns the character at the specified index in the string s.

func AtRunes

func AtRunes(r []rune, index int) string

AtRunes returns the character at the specified index in given array of rune.

func Between

func Between(s, start, end string) (result []string)

Between returns an array of strings between the start and end string.

func CollapseWhitespace

func CollapseWhitespace(s string) string

CollapseWhitespace replaces consecutive whitespace characters with a single space in string s.

func Contains

func Contains(s, substr string, caseSensitive bool) bool

Contains reports whether substr is within s.

func ContainsAll

func ContainsAll(s, chars string, caseSensitive bool) bool

ContainsAll reports whether all of Unicode code points in chars contained in s.

func ContainsAny

func ContainsAny(s, chars string, caseSensitive bool) bool

ContainsAny reports whether any Unicode code points in chars are within s.

func CountSubstr

func CountSubstr(s, sep string, caseSensitive bool) int

CountSubstr counts the number of non-overlapping instances of sep in s.

func EndsWith

func EndsWith(s, search string, caseSensitive bool) bool

EndsWith tests whether the string s ends with string search.

func EnsureLeft

func EnsureLeft(s, substr string, caseSensitive bool) string

EnsureLeft prepends substr to s if s doesn't starts with substr.

func EnsureRight

func EnsureRight(s, substr string, caseSensitive bool) string

EnsureRight appends substr to s if s doesn't ends with substr.

func Insert

func Insert(s, substr string, index int) string

Insert insert substr into string s at the provided index.

func Length

func Length(s string) int

Length returns number of characters stirng s.

func PaddingBoth

func PaddingBoth(s, pad string, length int) string

PaddingBoth pad a string to a certain length with another string in both right and left side.

func PaddingLeft

func PaddingLeft(s, pad string, length int) string

PaddingLeft pad a string to a certain length with another string in left side.

func PaddingRight

func PaddingRight(s, pad string, length int) string

PaddingRight pad a string to a certain length with another string in right side.

func Prepend

func Prepend(s string, strs ...string) string

Prepend returns string s starting with strigns strs.

func PrependArray

func PrependArray(s string, strs []string) string

PrependArray returns string s starting with array strigns strs.

func RemoveLeft

func RemoveLeft(s, substr string, caseSensitive bool) string

RemoveLeft remove substr from start of string s if present.

func RemoveRight

func RemoveRight(s, substr string, caseSensitive bool) string

RemoveRight remove substr from end of string s if present.

func Reverse

func Reverse(s string) string

Reverse returns its argument string reversed rune-wise left to right.

func Runes

func Runes(s string) []rune

Runes converts the string s to an array of rune and returns it.

func Shuffle

func Shuffle(s string) string

Shuffle returns string s with its characters in random order.

func StartsWith

func StartsWith(s, search string, caseSensitive bool) bool

StartsWith tests whether the string s starts with string search.

func Substr

func Substr(s string, start int) string

Substr returns part of string s.

func SubstrLen

func SubstrLen(s string, start, length int) (str string)

SubstrLen returns part of string s.

func Surround

func Surround(s, substr string) string

Surround surrounds strings with given string substr.

func SurroundPad

func SurroundPad(s, pad string, leftPad, rightPad int) string

SurroundPad repeats characters of pad around given string s. number of repeats in left and right side specifies by leftPad and rightPad.

Types

This section is empty.

Jump to

Keyboard shortcuts

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