gstr

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NotFoundIndex is the position index for string not found in searching functions.
	NotFoundIndex = -1
)

Variables

This section is empty.

Functions

func Pos

func Pos(haystack, needle string, startOffset ...int) int

Pos returns the position of the first occurrence of `needle` in `haystack` from `startOffset`, case-sensitively. It returns -1, if not found.

func PosI

func PosI(haystack, needle string, startOffset ...int) int

PosI returns the position of the first occurrence of `needle` in `haystack` from `startOffset`, case-insensitively. It returns -1, if not found.

func PosIRune

func PosIRune(haystack, needle string, startOffset ...int) int

PosIRune acts like function PosI but considers `haystack` and `needle` as unicode string.

func PosR

func PosR(haystack, needle string, startOffset ...int) int

PosR returns the position of the last occurrence of `needle` in `haystack` from `startOffset`, case-sensitively. It returns -1, if not found.

func PosRI

func PosRI(haystack, needle string, startOffset ...int) int

PosRI returns the position of the last occurrence of `needle` in `haystack` from `startOffset`, case-insensitively. It returns -1, if not found.

func PosRIRune

func PosRIRune(haystack, needle string, startOffset ...int) int

PosRIRune acts like function PosRI but considers `haystack` and `needle` as unicode string.

func PosRRune

func PosRRune(haystack, needle string, startOffset ...int) int

PosRRune acts like function PosR but considers `haystack` and `needle` as unicode string.

func PosRune

func PosRune(haystack, needle string, startOffset ...int) int

PosRune acts like function Pos but considers `haystack` and `needle` as unicode string.

func QuoteMeta

func QuoteMeta(str string, chars ...string) string

QuoteMeta returns a version of `str` with a backslash character (`\`). If custom chars `chars` not given, it uses default chars: .\+*?[^]($)

func Replace

func Replace(origin, search, replace string, count ...int) string

Replace returns a copy of the string `origin` in which string `search` replaced by `replace` case-sensitively.

func ReplaceByArray

func ReplaceByArray(origin string, array []string) string

ReplaceByArray returns a copy of `origin`, which is replaced by a slice in order, case-sensitively.

func ReplaceByMap

func ReplaceByMap(origin string, replaces map[string]string) string

ReplaceByMap returns a copy of `origin`, which is replaced by a map in unordered way, case-sensitively.

func ReplaceI

func ReplaceI(origin, search, replace string, count ...int) string

ReplaceI returns a copy of the string `origin` in which string `search` replaced by `replace` case-insensitively.

func ReplaceIByArray

func ReplaceIByArray(origin string, array []string) string

ReplaceIByArray returns a copy of `origin`, which is replaced by a slice in order, case-insensitively.

func ReplaceIByMap

func ReplaceIByMap(origin string, replaces map[string]string) string

ReplaceIByMap returns a copy of `origin`, which is replaced by a map in unordered way, case-insensitively.

Types

This section is empty.

Jump to

Keyboard shortcuts

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