2

I have a string "value" and need to convert it to "Value" how can we do that using camel case Output : value = Value

Vani
  • 31
  • 2

1 Answers1

3

You can use string:titlecase/1:

> string:titlecase("value").
"Value"

Edit: this would technically not be a full camel case implementation (which would need to split on some character and title case each chunk), but it satisfies your example.

For converting snake_case to CamelCase, for instance, you could do:

> String = "hello_world",
  Chunks = string:split(String, "_"),
  Chunks2 = lists:map(fun string:titlecase/1, Chunks),
  string:join(Chunks2, "").
"HelloWorld"
sabiwara
  • 2,775
  • 6
  • 11