ystring

package
Version: v0.0.0-...-a823632 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: MIT Imports: 3 Imported by: 13

Documentation

Overview

Package ystring is yet another collection of helper methods to manipulate UTF-8 encoded strings.

Index

Constants

View Source
const NewLine string = "\n"

Variables

This section is empty.

Functions

func IsBlank

func IsBlank(s string) bool

IsBlank checks if the string contains only whitespaces.

func IsEmpty

func IsEmpty(s string) bool

IsEmpty checks if the string is empty.

func IsNotBlank

func IsNotBlank(s string) bool

IsNotBlank checks if the string contains any non-whitespace characters.

func IsNotEmpty

func IsNotEmpty(s string) bool

IsNotEmpty checks if the string is not empty.

func Length

func Length(s string) int

Length returns the number of runes in a given string.

func NotBlankOrDefault

func NotBlankOrDefault(s, fallback string) string

NotBlankOrDefault returns the string if it is not blank, or returns the fallback.

func NotEmptyOrDefault

func NotEmptyOrDefault(s, fallback string) string

NotEmptyOrDefault returns the string if it is not empty, or returns the fallback.

func Shrink

func Shrink(s, sep string) string

Shrink returns a string that replaces consecutive whitespace characters in s with the sep string.

func TrimAfterFirst

func TrimAfterFirst(s, substr string) string

TrimAfterFirst returns s without the part after the first instance of substr and that instance itself. If substr is empty or not present in s, s is returned unchanged.

func TrimAfterLast

func TrimAfterLast(s, substr string) string

TrimAfterLast returns s without the part after the last instance of substr and that instance itself. If substr is empty or not present in s, s is returned unchanged.

func TrimBeforeFirst

func TrimBeforeFirst(s, substr string) string

TrimBeforeFirst returns s without the part before the first instance of substr and that instance itself. If substr is empty or not present in s, s is returned unchanged.

func TrimBeforeLast

func TrimBeforeLast(s, substr string) string

TrimBeforeLast returns s without the part before the last instance of substr and that instance itself. If substr is empty or not present in s, s is returned unchanged.

func Truncate

func Truncate(s string, n int) string

Truncate returns first n runes of s.

Types

This section is empty.

Jump to

Keyboard shortcuts

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