Introduction to Regular Expressions
Get a taste of regular expressions (regex), a powerful search pattern language to quickly find the text you're looking for.
StartKey Concepts
Review core concepts you need to learn to master this subject
Character Sets in Regular Expressions
Optional Quantifiers in Regular Expressions
Literals in Regular Expressions
Fixed Quantifiers in Regular Expressions
Alternation in Regular Expressions
Anchors in Regular Expressions
Regular Expressions
Wildcards in Regular expressions
Character Sets in Regular Expressions
Character Sets in Regular Expressions
Regular expression character sets denoted by a pair of brackets []
will match any of the characters included within the brackets. For example, the regular expression con[sc]en[sc]us
will match any of the spellings consensus
, concensus
, consencus
, and concencus
.
- 1When registering an account for a new social media app or completing an order for a gift online, nearly every piece of information you enter into a web form is validated. Did you enter a properly f…
- 3Do you love baboons and gorillas? You can find either of them with the same regular expression using alternation! Alternation, performed in regular expressions with the pipe symbol, |, allows…
- 4Spelling tests may seem like a distant memory from grade school, but we ultimately take them every day while typing. It’s easy to make mistakes on commonly misspelled words like consensus, and on t…
- 5Sometimes we don’t care exactly WHAT characters are in a text, just that there are SOME characters. Enter the wildcard .! Wildcards will match any single character (letter, number, symbol or …
- 7While character ranges are extremely useful, they can be cumbersome to write out every single time you want to match common ranges such as those that designate alphabetical characters or digits. To…
- 9Here’s where things start to get really interesting. So far we have only matched text on a character by character basis. But instead of writing the regex \w\w\w\w\w\w\s\w\w\w\w\w\w, which would mat…
- 10You are working on a research project that summarizes the findings of primate behavioral scientists from around the world. Of particular interest to you are the scientists’ observations of humor in…
- 11In 1951, mathematician Stephen Cole Kleene developed a system to match patterns in written language with mathematical notation. This notation is now known as regular expressions! In his honor, the…
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory