This is now available natively as RegExp.escape(). You can also use this to escape a string that is inserted into the middle of a regex, for example, into a character ...
We independently review everything we recommend. When you buy through our links, we may earn a commission. Learn more› By Doug Mahoney Doug Mahoney is a writer covering home-improvement topics, ...