var strString = "My Name"; var strJustUppers = strString.replace(/[a-z]/g,""); // replace lower case letters with nothing var strJustUppers = strJustUppers.replace(/\s/g,""); // replace spaces with nothing