Ask Ben: Javascript String Replace Method

// So let's try to do a global replace using regular expressions.
strReplaceAll = strText.replace( new RegExp( "th", "g" ), "[X]" );
 
alert( strReplaceAll );

For Cut-and-Paste