var string = ' abc def ghi '; var test = string.split(/\s+/); alert(test.length);
var string = ' abc def ghi '; var test = string.match(/(\S+)/g); alert(test.length);