stringsutil

package
v0.0.195 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToTitleOrUpper

func ToTitleOrUpper(value string) string

ToTitleOrUpper converts the input string to title case or upper case based on its content. If the string contains more uppercase characters than lowercase characters, it converts the entire string to uppercase. Otherwise, it converts the string to title case.

Example:

ToTitleOrUpper("hello WORLD") // returns "HELLO WORLD"
ToTitleOrUpper("hello world") // returns "Hello World"

Types

type Formatter

type Formatter[T ~string] struct {
	// contains filtered or unexported fields
}

func NewFormatter

func NewFormatter[T ~string](value T) *Formatter[T]

func (*Formatter[T]) RemoveSpaces

func (formatter *Formatter[T]) RemoveSpaces() *Formatter[T]

func (*Formatter[T]) ToLower

func (formatter *Formatter[T]) ToLower() *Formatter[T]

func (*Formatter[T]) ToUpper

func (formatter *Formatter[T]) ToUpper() *Formatter[T]

func (*Formatter[T]) TrimSpaces

func (formatter *Formatter[T]) TrimSpaces() *Formatter[T]

func (*Formatter[T]) Value

func (formatter *Formatter[T]) Value() T

Value returns the formatted value.

Jump to

Keyboard shortcuts

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