2026-02-18 06:55:01 -07:00
|
|
|
# regex
|
|
|
|
|
|
|
|
|
|
> Regular expressions (`regex`) are patterns used to match, search, and manipulate text.
|
|
|
|
|
> Note: `regex` isn't a command, but syntax to be used with other commands.
|
2026-08-06 22:19:46 -06:00
|
|
|
> See also: `egrep`, `glob`.
|
2026-02-18 06:55:01 -07:00
|
|
|
> More information: <https://cheatography.com/davechild/cheat-sheets/regular-expressions/>.
|
|
|
|
|
|
|
|
|
|
- Match any single character:
|
|
|
|
|
|
|
|
|
|
`.`
|
|
|
|
|
|
|
|
|
|
- Match the start of a line:
|
|
|
|
|
|
|
|
|
|
`^{{hello}}`
|
|
|
|
|
|
|
|
|
|
- Match the end of a line:
|
|
|
|
|
|
|
|
|
|
`{{world}}$`
|
|
|
|
|
|
|
|
|
|
- Match zero or more repeated characters:
|
|
|
|
|
|
|
|
|
|
`{{a}}*`
|
|
|
|
|
|
2026-08-06 22:19:46 -06:00
|
|
|
- Match one character in a set of characters:
|
2026-02-18 06:55:01 -07:00
|
|
|
|
|
|
|
|
`[{{abc}}]`
|
|
|
|
|
|
|
|
|
|
- Match ranges of characters:
|
|
|
|
|
|
|
|
|
|
`[{{a-z}}][{{3-9}}]`
|
|
|
|
|
|
|
|
|
|
- Match anything but the specified character:
|
|
|
|
|
|
|
|
|
|
`[^{{a}}]`
|
|
|
|
|
|
|
|
|
|
- Match a boundary around a word:
|
|
|
|
|
|
|
|
|
|
`"\b{{text}}\b"`
|