// Let's take a look at the above example using regular expressions. strReplaceSimple = strText.replace( new RegExp( "th", "" ), "[X]" ); alert( strReplaceSimple );