chickadee » regex » regexp-escape

regexp-escape STRINGprocedure

Escapes all special characters in STRING with \, so that the string can be embedded into a regular expression.

(regexp-escape "^[0-9]+:.*$")
=>  "\\^\\[0-9\\]\\+:.\n.\\*\\$"