title: How to know if JavaScript string.replace() did anything?
body: <p>The <code>replace</code> function returns the new string with the replaces, but if there weren't any words to replace, then the original string is returned. Is there a way to know whether it actually replaced anything apart from comparing the result with the original string?</p>