ds

package
v0.0.0-...-326b91d Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2019 License: MIT Imports: 2 Imported by: 2

Documentation

Overview

Package ds provides useless string functions which (s)c(h)ould be in "strings" but are not (yet) there.

Note: `ds` is shorthand for `do strings`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(text, left, right string) (string, error)

Extract all text bracketed by left & right

TODO: return error, if some right found before next left

func Join2

func Join2(a, b string, sep string) string

Join2 (a convenience for strings.Join) only joins, if both args are non-empty

func SplitAllPrefixe

func SplitAllPrefixe(text, prefix string) (head, tail string)

SplitAllPrefixe looks for all occurrences of prefix and returns them as head, and text less them as tail. Invariant: len(text) == len(head) + len(tail)

func SplitAllSuffixe

func SplitAllSuffixe(text, suffix string) (head, tail string)

SplitAllSuffixe looks for all occurrences of suffix and returns them as tail, and text less them as head. Invariant: len(text) == len(head) + len(tail)

func SplitAtFirst

func SplitAtFirst(text, sep string) (head, tail string)

SplitAtFirst separates `text` at first `sep` into `head` and `tail`. If there is no `sep`, all `text` becomes `tail`.

func SplitAtFirstChar

func SplitAtFirstChar(text, sep string) (head, tail string)

SplitAtFirstChar splits text immediately following the first Separator, separating it into a head and tail component. If there is no Separator in text, head set to text and an empty tail are returned. The returned values have the property that text = head+tail. head hasSuffix sep if tail is not empty or if text hasSuffix sep and no more sep

SplitAtFirstChar panics if len(sep) != 1

func SplitAtLast

func SplitAtLast(text, sep string) (head, tail string)

SplitAtLast separates `text` at last `sep` into `head` and `tail`. If there is no `sep`, all `text` becomes `head`.

func SplitAtLastChar

func SplitAtLastChar(text, sep string) (head, tail string)

SplitAtLastChar splits text immediately following the last Separator, separating it into a head and tail component. If there is no Separator in text, an empty head and tail set to text are returned. The returned values have the property that text = head+tail. tail hasSuffix sep if head is not empty or if text hasPrefix sep and no more sep

SplitAtLastChar panics if len(sep) != 1

func UnBracket

func UnBracket(in, bo, bc string) string

UnBracket returns what it found between bo & bc

Types

This section is empty.

Jump to

Keyboard shortcuts

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