splitter

package module
v0.0.0-...-5999b2d Latest Latest
Warning

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

Go to latest
Published: May 30, 2015 License: MIT Imports: 1 Imported by: 1

README

splitter

String / Byte split by sep string / byte ignore the string sequence.

Installation

$ go get github.com/ysugimoto/splitter

Usage

Simple string split same strings.Split:

str := "Lorem ipsum dolor sit amet"
splitted := splitter.SplitString(str, " ")

fmt.Println(splitted)
// => []string{"Lorem", "ipsum", "dolor", "sit", "amet"}

spitter correctly split when sep string found in string sequence:

// famous case, command args split
str := "echo \"foo | bar | baz\" | grep bar"
splitted := splitter.SplitString(str, "|")

// strings.Split works all sep string
fmt.Println(strings.Split(str, "|")
// => []string{"echo \"foo ", " bar ", " baz\" ", " grep bar"}

// splitter.Split works out of sequence only
fmt.Println(splitted)
// => []string{"echo \"foo | bar | baz\" ", " grep bar"}

Author

Yoshiaki Sugimoto

License

MIT

Documentation

Index

Constants

View Source
const (
	SQ = 39
	DQ = 34
)

Variables

This section is empty.

Functions

func SplitBytes

func SplitBytes(bt, sep []byte) (result [][]byte)

func SplitString

func SplitString(str, sep string) (result []string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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