doomemacs/lisp/lib/strings.el

16 lines
407 B
EmacsLisp
Raw Normal View History

;;; lisp/lib/strings.el -*- lexical-binding: t; -*-
;;;###autoload
(defun doom-pcre-quote (str)
"Like `reqexp-quote', but for PCREs."
(let ((special '(?. ?^ ?$ ?* ?+ ?? ?{ ?\\ ?\[ ?\| ?\())
(quoted nil))
(mapc (lambda (c)
(when (memq c special)
(push ?\\ quoted))
(push c quoted))
str)
(concat (nreverse quoted))))
;;; end of strings.el