initial caps in actionScript using Regex
Posted
by Deyon
on Stack Overflow
See other posts from Stack Overflow
or by Deyon
Published on 2010-04-18T20:04:36Z
Indexed on
2010/04/18
20:13 UTC
Read the original article
Hit count: 360
I'm trying to do initial caps in actionScript with no loops but now i'm stuck. I wanted to select the first letter or every word then apply uppercase on that letter. Well I got the selection part right, but at a dead end right now, any ideas? I was trying to do this with out loops and cutting up strings.
//replaces with x cant figure out how to replace with the found result as uppercase
public function initialcaps():void
{
var pattern:RegExp=/\b[a-z]/g;
var myString:String="yes that is my dog dancing on the stage";
var nuString:String=myString.replace(pattern,"x");
trace(nuString);
}
© Stack Overflow or respective owner