<--- --------------------------------------------------------------------------------------- ---- Blog Entry: Ask Ben: Javascript String Replace Method Author: Ben Nadel / Kinky Solutions Link: http://www.bennadel.com/index.cfm?dax=blog:142.view Date Posted: Jul 17, 2006 at 7:36 AM ---- --------------------------------------------------------------------------------------- ---> // This counts the number of times a string matching the // given regular expression can be found in the given text. function CountValue( strText, reTargetString ){ var intCount = 0; // Use replace to globally iterate over the matching // strings. strText.replace( reTargetString, // This function will get called for each match // of the regular expression. function(){ intCount++; } ); // Return the updated count variable. return( intCount ); }