stringy icon indicating copy to clipboard operation
stringy copied to clipboard

Would really like a "SentenceCase"

Open nyetwurk opened this issue 1 year ago • 0 comments

Something that converts from CamelCase, snake_case, kebab-case to Sentence case

e.g. ThisIsCamelCase to This is camel case

func (i *input) SentenceCase(rule ...string) StringManipulation {
	input := getInput(*i)
	wordArray := caseHelper(input, false, rule...)
	i.Result = strings.Join(wordArray, " ")
	return i
}

I have code like this but it is pretty ugly (converts to snake case then replaces _ with -):

s := stringy.New(str)
str = strings.ReplaceAll(s.SnakeCase("?", "").ToLower(), "_", " ")
return stringy.New(str).UcFirst()

Also it would be nice to be able to chain ToLower() w/o a new stringy.

nyetwurk avatar Apr 09 '23 08:04 nyetwurk