strings

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package strings provides functions for manipulating strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base58ToHex

func Base58ToHex(input string) (output string, err error)

Base58ToHex converts a base58-encoded string to hex.

func Capitalize

func Capitalize(input string) string

Capitalize capitalizes the first letter of a string.

func EnsureAlphanumeric

func EnsureAlphanumeric(input string) string

EnsureAlphanumeric removes any non-alphanumeric characters from a string.

func ExtractLinks(haystack string) ([]string, error)

ExtractLinks returns links from a plain/text body.

func ExtractLinksWithValidator

func ExtractLinksWithValidator(haystack string, isLink func(input string) (bool, string)) ([]string, error)

ExtractLinksWithValidator returns links from a plain/text body, using a custom function to validate links.

func FoldWhitespace

func FoldWhitespace(input string) (string, error)

FoldWhitespace normalizes whitespace.

func FormatString

func FormatString(input string, replacements []string) string

FormatString formats a string, replacing % numeric expressions with their corresponding array values.

func HexToBase58

func HexToBase58(input string) (output string, err error)

HexToBase58 converts a hex-encoded string to base58.

func IsAlphanumeric

func IsAlphanumeric(input string) bool

IsAlphanumeric returns true if the string consists of only letters and numbers.

func IsWhitespace

func IsWhitespace(r rune) bool

IsWhitespace returns true if the rune is whitespace.

func NormalizeCharSet

func NormalizeCharSet(charSet string) string

NormalizeCharSet replaces aliased character sets with their more common representation.

func NormalizePhone

func NormalizePhone(input string) (string, error)

NormalizePhone formats phone numbers consistently.

func Permutations

func Permutations(input []string) [][]string

Permutations returns all permutations made through combinations of input nodes.

func RemoveAny

func RemoveAny(haystack string, needles string) (string, error)

RemoveAny removes any matching needle characters.

func RemoveUnreadableCharacters

func RemoveUnreadableCharacters(input string) (string, error)

RemoveUnreadableCharacters removes non-human readable characters.

func RemoveWhitespace

func RemoveWhitespace(input string) (string, error)

RemoveWhitespace removes whitespace.

func ReturnAllBetween

func ReturnAllBetween(haystack string, startNeedle string, endNeedle string) []string

ReturnAllBetween returns all substrings in haystack between startNeedle and endNeedle.

func ReturnAllBetweenArray

func ReturnAllBetweenArray(haystack string, startNeedles []string, endNeedles []string) []string

ReturnAllBetweenArray returns all substrings in haystack between entries of startNeedles and entries of endNeedles.

func ReturnAllBetweenInsensitive

func ReturnAllBetweenInsensitive(haystack string, startNeedle string, endNeedle string) []string

ReturnAllBetweenInsensitive returns all substrings in haystack between startNeedle and endNeedle, case insensitive.

func ReturnAndRemoveAllBetween

func ReturnAndRemoveAllBetween(haystack string, startNeedle string, endNeedle string, removeNeedles bool) (string, []string)

ReturnAndRemoveAllBetween returns all substrings in haystack between startNeedle and endNeedle, and removes them.

func ReturnBetween

func ReturnBetween(haystack string, startNeedle string, endNeedle string) string

ReturnBetween returns the substring in haystack between startNeedle and endNeedle.

func ReturnBetweenInsensitive

func ReturnBetweenInsensitive(haystack string, startNeedle string, endNeedle string) string

ReturnBetweenInsensitive returns the substring in haystack between startNeedle and endNeedle, case insensitive.

func SplitAny

func SplitAny(haystack string, needles string) []string

SplitAny splits haystack on any matching needle characters.

Types

This section is empty.

Jump to

Keyboard shortcuts

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