<--- --------------------------------------------------------------------------------------- ---- Blog Entry: Using Methods in Javascript Replace Method Author: Ben Nadel / Kinky Solutions Link: http://www.bennadel.com/index.cfm?dax=blog:55.view Date Posted: May 15, 2006 at 8:14 AM ---- --------------------------------------------------------------------------------------- ---> String.prototype.GetSmallWords = function(){ // Declare the array that will hold the small words matches. var arrWords = new Array(); // Take the string value and get copy the small words into an array. this.replace( new RegExp("(a|and|be|do|for|go|he|hi|i|in|is|no|of|on|the|to)", "gi"), // This replace function takes the word found and adds the // word to the locally-defined array of short words in the // parent function. function( strWord ){ arrWords[ arrWords.length ] = strWord; } ); // Return the array of little words. return( arrWords ); } // Create a test string with small words. var strTest = "Ben Nadel is a Pretty Nice Guy. I really like Kinky Solutions and his Coding Style."; // Alert the array of small words. alert( strTest.GetSmallWords() );