inflect

package
v0.24.5 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package inflect provides (some) english language string transformation utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capitalize

func Capitalize(s string) (ret string)

Capitalize returns a new string, starting the first word with a capital.

func Fields

func Fields(s string) []string

Fields is similar to strings.Fields except it follows the rules of inflect.IsSpace

func FirstWord

func FirstWord(s string) string

given a normalized phrase, return the first word ( exists to try to break up dependence on space as the separator of words )

func IsCapitalized

func IsCapitalized(n string) (ret bool)

IsCapitalized returns true if the passed string starts with an upper case letter.

func IsSpace

func IsSpace(r rune) (ret bool)

IsSpace reports whether the rune is a space character as defined by lower ascii. '\t', '\n', '\v', '\f', '\r', ' ' it specifically excludes non-breaking spaces.

func Join

func Join(els []string) string

func MixedCaseToSpaces

func MixedCaseToSpaces(s string) string

MixedCaseToSpaces takes a MixedCaseWord and splits it into lowercase words ( ex. mixed case word )

func Normalize

func Normalize(s string) string

Normalize lowercases the passed string, trims spaces, and eats some kinds of punctuation. Ascii underscores (_) are treated as whitespace, ascii dashes (-) are kept; all other unicode punctuation gets removed. Whitespace gets removed at the front and end of the strings; any remaining groups of one or more ws characters get replaced by a single space.

func NumToWords

func NumToWords(n int) (ret string, okay bool)

for WordsToNum, see match.

func Pluralize

func Pluralize(s string) (ret string)

Pluralize attempts to return the plural form of the passed assumed singular string.

func SentenceCase

func SentenceCase(s string) string

SentenceCase returns the passed string in lowercase, starting new sentences with capital letters.

func Singularize

func Singularize(s string) (ret string)

Singularize attempts to return the singular form of the passed assumed plural string.

func Titlecase

func Titlecase(s string) (ret string)

Titlecase returns a new string, starting every word with a capital.

Types

This section is empty.

Jump to

Keyboard shortcuts

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