string title bif?

Wes James <>
Fri Jun 25 20:23:02 CEST 2010


Is there a BIF that does this (I can't find one, if there is):

string:title("this_is_a_title") -> "This Is A Title".

Or something like this?  If not I'll just create one.

It would need to split the string at the "_" and then uppercase the
first character of each word.

This test works:

-------------------

-module(title).

-export([start/0]).

start() ->
	title(string:tokens("this_is_a_title","_")).
	
title([H|T]) ->
	[fc_upper(H)|title(T)];
title([]) -> [].

fc_upper([C|R]) ->
	[string:to_upper(C)]++R.

----------------

thx.

-wes


More information about the erlang-questions mailing list