// using regex
var camelCase:String = "CamelCaseIsSexy";
function camelCase2human(s:String):String {
var myRegExp:RegExp = /(^[a-z]|[A-Z0-9])[a-z]*/g;
var catches:Object = s.match(myRegExp);
var humanReadable:String = "";
for( var j:String in catches ) {
humanReadable += catches[j] + " ";
}
return humanReadable;
}
trace( camelCase2human(camelCase);
2 comments:
public static function camelCase2human(s:String):String
{
var myRegExp:RegExp = /(^[a-z]|[A-Z0-9])[a-z]*/g;
var catches:Array = s.match(myRegExp);
var humanReadable:String = "";
return catches.join(" ");
}
Nice! Thank-you!
Post a Comment