Regular Expression: Difference between revisions
Jump to navigation
Jump to search
Created page with "==Basic RegEx Cheat Sheet== {| class="wikitable" ! Symbol !! Name !! Meaning !! Example !! Matches |- ! colspan="5" style="text-align:center;" | Literals |- | (text) || Literal || Matches exact text || <code>cat</code> || "cat" |- ! colspan="5" style="text-align:center;" | Wildcards & Classes |- | <code>.</code> || Dot || Matches '''any''' single character || <code>h.t</code> || "hat", "hot" |- | <code>[ ]</code> || Brackets || List of allowed characters || <code>b[ai]t..." |
|||
| Line 33: | Line 33: | ||
|- | |- | ||
| <code>\</code> || Escape || Treats special characters as text || <code>\.</code> || "." (actual dot) | | <code>\</code> || Escape || Treats special characters as text || <code>\.</code> || "." (actual dot) | ||
|- | |||
| <code>\</code> || Escape || Treats special characters as text || <code>\$</code> || "$" (actual dollar) | |||
|- | |- | ||
| <code>\d</code> || Digit || Any number 0-9 || <code>\d\d</code> || "42", "99" | | <code>\d</code> || Digit || Any number 0-9 || <code>\d\d</code> || "42", "99" | ||
Revision as of 17:33, 23 January 2026
Basic RegEx Cheat Sheet
| Symbol | Name | Meaning | Example | Matches |
|---|---|---|---|---|
| Literals | ||||
| (text) | Literal | Matches exact text | cat |
"cat" |
| Wildcards & Classes | ||||
. |
Dot | Matches any single character | h.t |
"hat", "hot" |
[ ] |
Brackets | List of allowed characters | b[ai]t |
"bat", "bit" |
[^ ] |
Negation | Matches anything NOT in the list | [^a] |
Any char except 'a' |
| Quantifiers | ||||
* |
Star | 0 or more times | go*d |
"gd", "god", "good" |
+ |
Plus | 1 or more times | go+d |
"god", "good" |
? |
Question | 0 or 1 time (Optional) | colou?r |
"color", "colour" |
| Anchors | ||||
^ |
Caret | Start of string | ^The |
"The end" |
$ |
Dollar | End of string | end$ |
"The end" |
| Special Characters | ||||
\ |
Escape | Treats special characters as text | \. |
"." (actual dot) |
\ |
Escape | Treats special characters as text | \$ |
"$" (actual dollar) |
\d |
Digit | Any number 0-9 | \d\d |
"42", "99" |
\w |
Word | Letter, number, or underscore | \w+ |
"Hello_1" |
\s |
Space | Whitespace (space, tab, enter) | A\sB |
"A B" |