strutil

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: BSD-2-Clause Imports: 3 Imported by: 1

Documentation

Overview

Package strutil provides string utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelToDashed

func CamelToDashed(camel string) string

CamelToDashed converts a CamelCaseIdentifier to a dash-separated-identifier, or a camelCaseIdentifier to a -dash-separated-identifier. All-cap words are converted to lower case; HTTP becomes http and HTTPRequest becomes http-request.

func ChopLineEnding

func ChopLineEnding(s string) string

ChopLineEnding removes a line ending ("\r\n" or "\n") from the end of s. It returns s if it doesn't end with a line ending.

func ChopTerminator

func ChopTerminator(s string, terminator byte) string

ChopTerminator removes a specific terminator byte from the end of s. It returns s if it doesn't end with the specified terminator.

func FindFirstEOL

func FindFirstEOL(s string) int

FindFirstEOL returns the index of the first '\n'. When there is no '\n', the length of s is returned.

func FindLastSOL

func FindLastSOL(s string) int

FindLastSOL returns an index just after the last '\n'.

func HasSubseq

func HasSubseq(s, t string) bool

HasSubseq determines whether s has t as its subsequence. A string t is a subsequence of a string s if and only if there is a possible sequence of steps of deleting characters from s that result in t.

func JoinLines added in v0.21.0

func JoinLines(lines []string) string

JoinLines appends each line with a "\n" and joins all of them.

func Title added in v0.19.0

func Title(s string) string

Title returns s with the first codepoint changed to title case.

Types

This section is empty.

Jump to

Keyboard shortcuts

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