How do I prevent regex expansion on substitutions?
Sometimes you want to match regular expression metacharacters as literals (e.g., you want to match “[0-9]” or “\n”), to be replaced with something else. The ordinary way to prevent expanding metacharacters is to prefix them with a backslash. Thus, if “\n” matches a newline, “\\n” will match the two-character string of ‘backslash’ followed by ‘n’. But doing this repeatedly can become tedious if there are many regexes.