Emacs: Wildcards vs Regular Expression
What is String Wildcards (Glob Pattern)
In shell, you can use wildcards to match filename,
to list all jpg files.
This system is called
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
- Match any character.
Match a range of characters x to y.
Typically used as
[0-9]. the range is defined by the char's id.
Match any characters in chars.
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 Regular Expression
- Regular Expression
- About Quoting Regex
- Regex Syntax
- Case Sensitivity
- How to Insert a Tab or Newline
- Wildcards vs Regex