If someone suggested that you write a function which, given a person’s name, tells you what gender they are, you might caution that this is a hard problem. You might suggest a solution like a Bayesian classifier, which could be trained, or you might say, “Maybe we should just let the users tell us.”

There are a few things you almost certainly wouldn’t suggest. You wouldn’t suggest using ColdFusion , because CF is constructed out of sin and unicorn tears. And you certainly wouldn’t suggest trying to use regexes to do this job.

That’s because you aren’t Brent’s co-worker, who wrote this:

this.genderize(Arguments.firstName)

<cffunction name="Genderize" output="false" returnType="string">
       <cfargument name="Name" type="string" required="true">

       <cfscript>
              var regex = "";

              regex = "(ua|pher|andy|elijah)$";
              if (REFindNoCase(regex, Arguments.name)) {return "male";}

              regex = "(a|i|y|ah|ee|et|ette|elle|fer|ine|lyn|ie|anne|een|en|er|yn|ynn|kim|rachel|lind|pam|sue)$";
              if (REFindNoCase(regex, Arguments.name)) {return "female";}

              return "male";
       </cfscript>
</cffunction>
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!