goStringSlicer

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 2 Imported by: 0

README

goStringSlicer

Fast and memory-frendly string slicer

Description

  • indexing by letters
  • O(n)
  • Do not use additional memory (just for result)
  • Support negative indexes

examples

import "goStringSlicer"

func main(){
    var sentense string = "Some Únicode"
    res, _ := SliceString(sentense, 0, 3) // res = "Som"
}

import "goStringSlicer"

func main(){
    var sentense string = "Some Únicode"
    res, _ := SliceString(sentense, -7, 8) // res = "Úni"
}

Also function can return some errors:

  • one of index or both out of bound
  • end index bigger than begin
import "goStringSlicer"

func main(){
    var sentense string = "Some Únicode"
    res, err := SliceString(sentense, -7, 8) // res = "Úni"
    if err == nil{
        // do something
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SliceString

func SliceString(data string, begin, end int) (string, error)

func SliceStringNegative added in v1.0.4

func SliceStringNegative(data string, begin, end int) (string, error)

slice string by runes. begin - start rune index for slice. end - end rune index to slice. end index will not be include.

func SliceStringPositive added in v1.0.4

func SliceStringPositive(data string, begin, end int) (string, error)

slice string by runes. begin - start rune index for slice. end - end rune index to slice. end index will not be include.

Types

This section is empty.

Jump to

Keyboard shortcuts

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