Emacs: Wildcards vs Regular Expression

By Xah Lee. Date: . Last updated: .

What is String Wildcards (Glob Pattern)

In shell, you can use wildcards to match filename, e.g. ls *.jpg to list all jpg files. This system is called string wildcards or known as glob pattern in unix. Wildcards is simple and easy to understand.

String Wildcard Syntax

There is no standard syntax. Here's a basic list of String Wildcard Syntax features supported by most tools.

*
Match 0 or more of any character. Example, *.jpg match all file names ending in .jpg.
?
Match any character.
[x-y]
Match a range of characters x to y.
Typically used as [a-z] and or [0-9]. the range is defined by the char's id.
[chars]
Match any characters in chars.
e.g. [abc].

Regular Expression for Matching More Complex Patterns

Regular Expression is much more powerful than wildcards.

Here's example of patterns that regex can represent, but wildcards cannot:

Emacs Regular Expression

Regex in Emacs Lisp

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Emacs Tutorial

Quick Start

Font

Split Window

File

Buffer

Find Replace

Copy/Paste

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Special File

Editing Brackets

Org Mode

HTML

Emacs Efficiency

Misc