stringsx

package
v0.0.0-...-adcb032 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: Apache-2.0 Imports: 4 Imported by: 10

README

stringsx

GoDoc

Package stringsx contains string utilities. It means to be a complement to the standard strings package.

Documentation

Overview

Package stringsx contains string utilities. It means to be a complement to the standard strings package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean(s string) string

Clean removes non-graphic characters from the given string. Removable characters are the ones for which unicode.IsGraphic() returns false.

For details, see https://stackoverflow.com/a/58994297/1705598

func LimitRunes

func LimitRunes(s string, n int) string

LimitRunes returns a slice of s that contains at most the given number of runes. If n is 0 or negative, the empty string is returned. If s has less runes than n, s is returned.

Each byte of invalid UTF-8 sequences count as one when counting the limit, e.g.

LimitRunes("\xff\xffab", 3) // returns "\xff\xffa"

func SplitQuotes

func SplitQuotes(s string, sep, quote rune) (parts []string)

SplitQuotes splits the given string by sep. If sep appears inside quotes, it is skipped. Quotes are not removed from the parts.

Types

type Pool

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

Pool implements a string pool safe for concurrent use.

For details, see https://stackoverflow.com/a/51983331/1705598

func NewPool

func NewPool() *Pool

NewPool returns a new, empty string pool.

func (*Pool) Interned

func (p *Pool) Interned(s string) string

Interned returns the string instance from the pool that is equal to s. If s is not yet in the pool, it is put into it and returned.

Jump to

Keyboard shortcuts

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