I've come across this regex in a search results pagination tutorial, but it doesn't really explain what function the regex helper (they call "escapeRegex") provides.
string.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
Can anyone explain what it does (or is trying to do)?