strsplit

package
v1.129.3 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 3 Imported by: 0

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

func Chunk(s string, size, n int) []string

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

func ChunkLine(s string, size, n int) []string

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.

Jump to

Keyboard shortcuts

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