Schemaphic Systems Blog

Sharing experiences in Flash, Flex and AIR

Remove all punctuations from a String

leave a comment »

var output:String = "";
var input:String = "There's a bright light seen around the corner of Cafe-coffee-day (C.C.D)!";

for (var i:int = 0; i < input.length; i++) {
    if ((input.charCodeAt(i) >= 65 && input.charCodeAt(i) <= 90) || (input.charCodeAt(i) >= 97 && input.charCodeAt(i) <= 122) || input.charCodeAt(i) == 32 ) {
        output= output.concat(input.charAt(i));
    }
}

trace(output); //Theres a bright light seen around the corner of Cafecoffeeday CCD
output = output.split( " " ).toString();
trace(output); //Theres,a,bright,light,seen,around,the,corner,of,Cafecoffeeday,CCD
Advertisements

Written by Deepanjan Das

October 7, 2010 at 9:04 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: