var s = " Adobe Flex is a good technology for implementing RIAs ";
//To remove leading spaces, i.e.spaces before the string s, use
s = s.replace( /^\s+/g,'');
//To remove trailing spaces, i.e.spaces after the string s, use
s = s.replace( /\s+$/g,'');
//To remove both spaces(i.e.both leading and trailing), use
s = s.replace( /^\s+/g,'').replace(/\s+$/g,'');
You never know, it might come in handy someday.