This lesson only lists down the basics of regular expressions. There are many other metacharacters available, and their combinations allow us to match complex patterns in texts.
If you are interested in learning more, below is a list of some more metacharacters (and the ones we studied in this lesson) used in regular expressions, along with their usage. Try experimenting with these metacharacters to create unique regular expressions.
Metacharacter | Character Name | Usage |
---|---|---|
[ ] | Square brackets | Matches set of characters specified within them |
. | Period | Matches any single character except newline |
^ | Caret | Matches the start of string |
$ | Dollar | Matches the end of string |
* | Asterik | Matches if there are zero or more repetitions |
+ | Plus | Matches if there are one or more repetitions |
\w | Lowercase w | Matches a single letter, digit, or underscore |
\W | Uppercase W | Matches any character which is not a part of \w |
\s | Lowercase s | Matches single whitespace character |
\S | Uppercase S | Matches any character which is not a part of \s |
\d | Lowercase d | Matches decimal digit in the range 0-9 |
\D | Uppercase D | Matches any character which is not a part of \d |
\t | Lowercase t | Matches tab |
\n | Lowercase n | Matches newline character |