[erlang-questions] String Pattern Matching

Luke Galea galeal@REDACTED
Sun Sep 7 16:02:37 CEST 2008


Hi all,

I get the sense that most erlangers feel that regular expressions  
aren't needed and that pattern matching can do the job.
I want to believe.
I really do.

But I am absolutely killing myself trying to port Ruby's  
ActiveSupport Inflector over to erlang. It lets you pluralize and  
singularize strings based on a set of rules.

For instance:
	([m|l])ouse$ -> $1ice
or
	([^aeiouy]|qu)y$ -> $1ies

So, given that erlang has insufficient regular expression support to  
tackle this (and given that I want to do this the "erlang way"), how  
does one go about doing this?

The bit syntax won't work on arbitrary length fields as far as I  
know. And I *really* don't want to invent my own subset/alternate  
syntax of regular expressions that is more than what erlang supports  
and less than a PCRE.

Thanks in advance,
-- Luke Galea



More information about the erlang-questions mailing list