Fast search and replace on strings or dom elements