[erlang-questions] String Pattern Matching

Vance Shipley <>
Sun Sep 7 20:47:46 CEST 2008

On Sun, Sep 07, 2008 at 10:02:37AM -0400, Luke Galea wrote:
}  I get the sense that most erlangers feel that regular expressions  
}  aren't needed and that pattern matching can do the job.

Whenever possible.

}  	([m|l])ouse$ -> $1ice


singularize(Word) ->
	L = lists:reverse(Word),

singularize1("ecil" ++ L) ->
	"esuol" ++ L;
singularize1("ecim" ++ L) ->
	"esuom" ++ L.

1> inflector:singularize("titmice").

If you're really just dealing in words the penalty of a double
reverse isn't as bad as the penalty of having to use REs.


More information about the erlang-questions mailing list