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 ¶
- func Extract(text, left, right string) (string, error)
- func Join2(a, b string, sep string) string
- func SplitAllPrefixe(text, prefix string) (head, tail string)
- func SplitAllSuffixe(text, suffix string) (head, tail string)
- func SplitAtFirst(text, sep string) (head, tail string)
- func SplitAtFirstChar(text, sep string) (head, tail string)
- func SplitAtLast(text, sep string) (head, tail string)
- func SplitAtLastChar(text, sep string) (head, tail string)
- func UnBracket(in, bo, bc string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Extract ¶
Extract all text bracketed by left & right
TODO: return error, if some right found before next left
func SplitAllPrefixe ¶
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 ¶
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 ¶
SplitAtFirst separates `text` at first `sep` into `head` and `tail`. If there is no `sep`, all `text` becomes `tail`.
func SplitAtFirstChar ¶
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 ¶
SplitAtLast separates `text` at last `sep` into `head` and `tail`. If there is no `sep`, all `text` becomes `head`.
func SplitAtLastChar ¶
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
Types ¶
This section is empty.