Documentation
¶
Overview ¶
Package strsplit contains utility functions to split Unicode strings.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chunk ¶
Chunk slices the input text block string s into substrings of maximum byte size at the closest separator. Account for Unicode strings to avoid splitting multi-byte characters. Newlines characters are applied first.
Example ¶
package main
import (
"fmt"
"github.com/tecnickcom/gogen/pkg/strsplit"
)
func main() {
str := "helloworld\nbellaciao"
d := strsplit.Chunk(str, 5, 3)
fmt.Println(d)
}
Output: [hello world bella]
func ChunkLine ¶
ChunkLine slices a string line into substrings of maximum byte size at the closest unicode space separator. Account for Unicode strings to avoid splitting multy-byte characters.
Example ¶
package main
import (
"fmt"
"github.com/tecnickcom/gogen/pkg/strsplit"
)
func main() {
str := "hello,world"
d := strsplit.ChunkLine(str, 8, -1)
fmt.Println(d)
}
Output: [hello, world]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.