Regular Expressions (Regex) are patterns which are widely used in many programming languages and softwares to search, match, and manipulate text.
Following are the examples of softwares that uses regex
Ctrl + F
to Find.Ctrl + H
to Replace.Symbol | Meaning | Example |
---|---|---|
. |
Matches any single character. | c.t → cat, cut, cot |
^ |
Matches the start of a line. | ^Hello → Line starts with "Hello". |
$ |
Matches the end of a line. | world$ → Line ends with "world". |
\d |
Matches any digit (0–9). | \d+ → 123, 4567 |
\w |
Matches any word character (a-z, A-Z, 0-9, _). | \w+ → hello123 |
\s |
Matches any whitespace (space, tab). | \s+ → spaces |
\b |
Matches a word boundary. | \bword\b → Exact match for "word". |
\ |
Escapes special characters. | \. → Matches a literal period. |
* |
Matches 0 or more occurrences. | ab*c → ac, abc, abbc |
+ |
Matches 1 or more occurrences. | ab+c → abc, abbc |
? |
Matches 0 or 1 occurrence. | colou?r → color, colour |
[] |
Matches a character set. | [aeiou] → Matches vowels. |
` | ` | Alternation (OR). |
() |
Groups expressions. | (ab)+ → ab, abab |
^\s{2,}
\b\d{2}:\d{2}:\d{2}\b
\n\n
\[[^\]]+\]
^
YourTextHere
-
to create a bullet list.$
YourTextHere
;
at the end of every line.^\s*$
\d+
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b
\s+$