stringsx

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyEmpty

func AnyEmpty(str ...string) bool

AnyEmpty strings

func DefaultIfEmpty

func DefaultIfEmpty(str string, defaultStr string) string

DefaultIfEmpty if the string return the defaultStr

func Empty

func Empty(str string) bool

Empty string

func NoneEmpty

func NoneEmpty(str ...string) bool

NoneEmpty strings

func NotEmpty

func NotEmpty(str string) bool

NotEmpty string

func ReplaceAll

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

ReplaceAll Replace all old in str with new

func Strip

func Strip(str string, stripChars string) string

Strip Delete the characters that start and end with stripChars

  • <p>Strips any of a set of characters from the start and end of a String.
  • This is similar to {@link String#trim()} but allows the characters
  • to be stripped to be controlled.</p> *
  • <p>A {@code EmptyStr} input String returns {@code EmptyStr}.
  • An empty string ("") input returns the empty string.</p> *
  • <p>If the stripChars String is {@code blank}, whitespace is
  • stripped as defined by {@link Empty(char)} *
  • <pre>
  • Strip("", *) = ""
  • Strip("abc", "") = "abc"
  • Strip(" abc", "") = "abc"
  • Strip("abc ", "") = "abc"
  • Strip(" abc ", "") = "abc"
  • Strip(" abcyx", "xyz") = " abc"
  • </pre>

func StripBlank

func StripBlank(str string) string

StripBlank Deletes leading and trailing whitespace characters

  • <p>Strips whitespace from the start and end of a String.</p> *
  • <p>This is similar to {@link Trim(String)} but removes whitespace.
  • Whitespace is defined by {@link Empty(char)}.</p> *
  • <pre>
  • StripBlank("") = ""
  • StripBlank(" ") = ""
  • StripBlank("abc") = "abc"
  • StripBlank(" abc") = "abc"
  • StripBlank("abc ") = "abc"
  • StripBlank(" abc ") = "abc"
  • StripBlank(" ab c ") = "ab c"
  • </pre>

func StripEnd

func StripEnd(str string, stripChars string) string

StripEnd Delete the characters that end with stripChars

  • <p>Strips any of a set of characters from the end of a String.</p> *
  • <p>A {@code EmptyStr} input String returns {@code EmptyStr}.
  • An empty string ("") input returns the empty string.</p> *
  • <p>If the stripChars String is {@code EmptyStr}, whitespace is
  • stripped as defined by {@link Empty(char)}.</p> *
  • <pre>
  • StripEnd("", *) = ""
  • StripEnd("abc", "") = "abc"
  • StripEnd("abc", null) = "abc"
  • StripEnd(" abc", null) = " abc"
  • StripEnd("abc ", null) = "abc"
  • StripEnd(" abc ", null) = " abc"
  • StripEnd(" abcyx", "xyz") = " abc"
  • StripEnd("120.00", ".0") = "12"
  • </pre>

func StripStart

func StripStart(str string, stripChars string) string

StripStart Delete the characters that start with stripChars

  • <p>Strips any of a set of characters from the start of a String.</p> *
  • <p>A {@code EmptyStr} input String returns {@code EmptyStr}.
  • An empty string ("") input returns the empty string.</p> *
  • <p>If the stripChars String is {@code EmptyStr}, whitespace is
  • stripped as defined by {@link Empty(char)}.</p> *
  • <pre>
  • StripStart("", *) = ""
  • StripStart("abc", "") = "abc"
  • StripStart("abc", "") = "abc"
  • StripStart(" abc", "") = "abc"
  • StripStart("abc ", "") = "abc "
  • StripStart(" abc ", "") = "abc "
  • StripStart("yxabc ", "xyz") = "abc "
  • </pre>

func ToBool

func ToBool(str string) bool

ToBool convert string to bool wrap strconv.ParseBool

func ToBytes

func ToBytes(str string) []byte

ToBytes concert string to bytes

func ToComplex

func ToComplex(str string) complex128

ToComplex convert string to complex wrap strconv.ParseComplex

func ToFloat64

func ToFloat64(str string) float64

ToFloat64 convert string to float64 wrap strconv.ParseFloat

func ToFloat64OrDefault added in v0.0.10

func ToFloat64OrDefault(str string, defVal float64) float64

ToFloat64OrDefault convert string to float64, if str empty or err you can get default value tha you want. wrap strconv.ParseFloat

func ToInt

func ToInt(str string) int

ToInt convert string int wrap strconv.Atoi

func ToIntOrDefault added in v0.0.10

func ToIntOrDefault(str string, defVal int) int

ToIntOrDefault convert string int, if str empty or err you can get default value tha you want. wrap strconv.Atoi

func ToUnit

func ToUnit(str string, base int) uint64

ToUnit convert string to unit If the base argument is 0, the true base is implied by the string's prefix following the sign (if present): 2 for "0b", 8 for "0" or "0o", 16 for "0x", and 10 otherwise. wrap strconv.ParseUint

func Trim

func Trim(str string) string

Trim the " " cutset

Types

type Builder

type Builder struct {
	strings.Builder
}

Builder extend from strings.Builder

func (*Builder) JoinByte

func (builder *Builder) JoinByte(bytes ...byte) (int, error)

JoinByte to current builder wrap JoinString

func (*Builder) JoinString

func (builder *Builder) JoinString(strArray ...string) (int, error)

JoinString to current builder

Jump to

Keyboard shortcuts

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