Cheat sheet for basic regex expressions and websites
Regex Expression | Function |
---|---|
\d | represents any digit 0 to 9 |
. | matches any single character as a wildcard |
[abc] | only matches a,b,c a single time, nothing else |
[^abc] | matches everything except a,b or c |
\w | matches A-Za-z0-9 |
[0-6] | matches every number between 0 and 6 |
[a-d] | matches every character between a and d |
a{3} | a must be there 3 times |
a{2-6} | a can be there 2 to 6 times |
\d* | any amount of numbers |
\d+ | any amount of numbers but at least one |
ab?c | b is an optional character, either abc or ac |
\t | matches a tab |
\n | represents a new line |
\r | carriage return |
\s | matches ANY whitespace |
^abc | expression starts with abc |
abc$ | and ends with abc |
^(file.+).pdf$ | matches a file beginning with “file” and ends with “.pdf”. Only captures filename! |
^(file.+.pdf$) | matches a file beginning with “file” and ends with “.pdf”. Captures both! |
(\w+ (\d+)) | matches “Jan 1987” as “Jan 1987” and “1987” |
(\d+)x(\d+) | captures everything divided by “x” and splits into two groups |
Pipe | or symbol |