> ## Content Index
> Fetch the complete content index at: https://sleepyforest.magicbytes.top/llms.txt
> Use this file to discover other available public pages before exploring further.

# Regex Cheat Sheet
- URL: https://sleepyforest.magicbytes.top/regex-cheat-sheet/
- Published: 2021-10-02T05:16:00.000Z
- Updated: 2021-10-27T03:19:25.000Z
- Author: Betty
- Tags: 笔记, 备忘单, Tech, #Import 2026-08-29 09:17

| Syntax | Description                                                                                             |
| ------ | ------------------------------------------------------------------------------------------------------- |
| \*     | 0 or more times                                                                                         |
| +      | 1 or more times                                                                                         |
| ?      | 1 or 0 times                                                                                            |
| {m}    | exactly m times                                                                                         |
| {m,}   | m or more times                                                                                         |
| {m,n}  | m to n times (both inclusive)                                                                           |
| \\n    | new line                                                                                                |
| \[…\]  | range or character class (e.g. \[a-z0-9\] all lowercases and digits)                                    |
| \[^…\] | not in range or negated character class (e.g. \[^0-9a-z\] everything but 0-9 and lower case characters) |
| .      | Any character except newline                                                                            |
| \\w    | Word character \[a-zA-Z0-9\_\]                                                                          |
| \\W    | Non-word character \[^a-zA-Z0-9\_\]                                                                     |
| \\d    | Digit character \[0-9\]                                                                                 |
| \\D    | Non-digit character \[^0-9\]                                                                            |
| \\s    | Whitespace character \[\\n\\r\\f\\t\]                                                                   |
| \\S    | Non-whitespace character \[^\\n\\r\\f\\t\]                                                              |
| ^      | The start of the line of text                                                                           |
| $      | The end of the line of text. (e.g. [\[1\]](#fn1)$ match an all-digit-and-dash string)                   |
| \\b    | Word boundary                                                                                           |
| \\B    | Not-word-boundary                                                                                       |
| i      | Case-insensitive matching m ^ and $ match next to embedded \\n                                          |
| (…)    | Group subpattern and capture submatch into \\1, \\2, ..                                                 |
| \\n    | Contains the result of nth earlier submatch from a parentheses capture group, or a named capture group  |

---

1. 0-9- [↩︎](#fnref1)

Ref: 

- [https://regexcheatsheet.com/](https://regexcheatsheet.com/?ref=sleepyforest.magicbytes.top)
- [https://www3.ntu.edu.sg/home/ehchua/programming/howto/Regexe.html](https://www3.ntu.edu.sg/home/ehchua/programming/howto/Regexe.html?ref=sleepyforest.magicbytes.top)