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