Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

is for patterns specifying search or replace strings. Also known as `regex` or `regexp`, the patterns describe strings to match when searching or replacing. Emacs provides extensive support for `regex` patterns in many commands. Emacs also provides an interactive expression builder for such patterns.

Written in a declarative language, patterns for matching text use a combination of special characters and ordinary characters. Many Emacs commands can use for searching, matching, replacing, and navigating. Emacs has several methods of entering search patterns, including the interactive re-builder and alternative syntax styles. Regex versions of and commands can also work incrementally like the .

Some commands include regex or regexp prefixes or suffixes. Common ones are replace-regexp, query-replace-regexp, align-regexp, highlight-regexp. But not all commands have in their names, such as multi-occur, how-many, keep-lines, flush-lines, grep, lgrep, and rgrep. Emacs uses patterns extensively.

Questions tagged with or should include additional tags or clarify which command is being used for regex matching.