Javascript Replace String Between Two Strings Are Anagrams