Emacs: Wildcards vs Regular Expression
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,
*.jpgmatch 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:
- Repetition of a character, a specific number of times.
- Repetition of a pattern.
- Pattern alternatives. (a βorβ condition of several patterns).
- A Pattern with condition on its boundary, such as at beginning of line, end of line, or separated by punctuation.
- Capture a pattern, to be used for replacement.
emacs and elisp regex
- Emacs: Regular Expression
- Emacs: List Matching Lines
- Emacs: Regular Expression Syntax
- Emacs: Regex Backslash in Command Prompt
- Emacs: Case Sensitivity in Text Search Commands
- Emacs: Insert Tab or Newline
- Emacs: Wildcards vs Regular Expression
- Elisp: Regular Expression
- Elisp: Regex Functions
- Elisp: Regex Backslash in Lisp Code
- Elisp: Case Sensitivity (case-fold-search)
- Elisp: Find Replace Text in Buffer
- Elisp: Match Data (Regex Result)
- Elisp: Unicode Escape Sequence
- Elisp: Convert Regex to Lisp Regex String
- Elisp: How to Test Regex
- Elisp: Regular Expression in Lisp Syntax, Rx (Package)
- Elisp: Regex Named Character Class and Syntax Table
- Emacs Regex vs Regex in Python, JavaScript, Java