The sheer number of backslashes my regexps require is pretty crazy. Does elisp have regexp literals, so I can write something like
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
One option is to use the
rx macro to construct your expressions using sexps.
Your example becomes
(rx "some" (group "regexp"))
Here are a couple more examples from the commentary section in rx.el, to get an idea of how
(rx (or (and line-start ";;" (0+ space) ?\n) (and line-start ?\n)))
(rx (and (zero-or-more (in " \t\n")) ":" (submatch (or line-end (one-or-more (not (any ?:)))))))
No it does not have regexp literals, but many find pcre2el to be a helpful alternative.
Specifically using it from elisp like this:
(rxt-pcre-to-elisp "(abc|def)\\w+\\d+") ;; => "\\(\\(?:abc\\|def\\)\\)[_[:alnum:]]+[[:digit:]]+"