Reputation: 31
I have a string "value" and need to convert it to "Value" how can we do that using camel case Output : value = Value
Upvotes: 2
Views: 213
Reputation: 3214
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"
Upvotes: 3