Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would really like a "SentenceCase" #23

Open
nyetwurk opened this issue Apr 9, 2023 · 0 comments
Open

Would really like a "SentenceCase" #23

nyetwurk opened this issue Apr 9, 2023 · 0 comments

Comments

@nyetwurk
Copy link

nyetwurk commented Apr 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant