Elisp: Regex Functions

By Xah Lee. Date: . Last updated: .

Search Text Functions for Buffer

〔see Elisp: Search Text Functions

Replace Match

〔see Elisp: Find Replace Text in Buffer

Get Captured Group

〔see Elisp: Match Data (Regex Result)

Regex Function for Matching in a String

〔see Elisp: String Functions

regexp-quote

regexp-quote

quote regex so it becomes plain text for regex functions.

(regexp-quote ".png")
;; "\\.png"

(regexp-quote "[template]")
;; "\\[template]"

(regexp-quote "(* comment. applescript ocaml pascal wolframlang *)")
;; "(\\* comment\\. applescript ocaml pascal wolframlang \\*)"

Emacs Lisp, Regex in Lisp Code