stringx

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidStartPosition is an error that indicates the start position is invalid.
	ErrInvalidStartPosition = errors.New("start position is invalid")
	// ErrInvalidStopPosition is an error that indicates the stop position is invalid.
	ErrInvalidStopPosition = errors.New("stop position is invalid")
)
View Source
var WhiteSpace = []rune{'\n', '\t', '\f', '\v', ' '}

Functions

func Contains

func Contains(list []string, str string) bool

Contains checks if str is in list.

func ContainsAny

func ContainsAny(s string, runes ...rune) bool

func ContainsWhiteSpace

func ContainsWhiteSpace(s string) bool

func Filter

func Filter(s string, filter func(r rune) bool) string

Filter filters chars from s with given filter function.

func FirstN

func FirstN(s string, n int, ellipsis ...string) string

FirstN returns first n runes from s.

func HasEmpty

func HasEmpty(args ...string) bool

HasEmpty checks if there are empty strings in args.

func NotEmpty

func NotEmpty(args ...string) bool

NotEmpty checks if all strings are not empty in args.

func Remove

func Remove(strings []string, strs ...string) []string

Remove removes given strs from strings.

func Reverse

func Reverse(s string) string

Reverse reverses s.

func Substr

func Substr(str string, start, stop int) (string, error)

Substr returns runes between start and stop [start, stop) regardless of the chars are ascii or utf8.

func TakeOne

func TakeOne(valid, or string) string

TakeOne returns valid string if not empty or later one.

func TakeWithPriority

func TakeWithPriority(fns ...func() string) string

TakeWithPriority returns the first not empty result from fns.

func Union

func Union(first, second []string) []string

Union merges the strings in first and second.

Types

type String

type String struct {
	// contains filtered or unexported fields
}

String provides for converting the source text into other spell case,like lower,snake,camel

func From

func From(data string) String

From converts the input text to String and returns it

func (String) IsEmptyOrSpace

func (s String) IsEmptyOrSpace() bool

IsEmptyOrSpace returns true if the length of the string value is 0 after call strings.TrimSpace, or else returns false

func (String) Lower

func (s String) Lower() string

Lower calls the strings.ToLower

func (String) ReplaceAll

func (s String) ReplaceAll(old, new string) string

ReplaceAll calls the strings.ReplaceAll

func (String) Source

func (s String) Source() string

Source returns the source string value

func (String) Title

func (s String) Title() string

Title calls the strings.Title

func (String) ToCamel

func (s String) ToCamel() string

ToCamel converts the input text into camel case

func (String) ToSnake

func (s String) ToSnake() string

ToSnake converts the input text into snake case

func (String) Untitle

func (s String) Untitle() string

Untitle return the original string if rune is not letter at index 0

func (String) Upper

func (s String) Upper() string

Upper calls the strings.ToUpper

Jump to

Keyboard shortcuts

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