Quick Notes
abc…Letters
 123…Digits
 \dany Digit
 .any Character
 \.Period
 [abc]Only a, b, or c
 [^abc]Not a, b, nor c
 [a-z]Characters a to z
 [0-9]Numbers 0 to 9
 {m}m Repetitions
 {m,n}m to n Repetitions
 *Zero or more repetitions
 +One or more repetitions
 ?Optional
 \sany Whitespace
 ^…$Starts and ends
 ()capture Group
 (a(bc))capture Sub group
 (.*)capture Variable content
 (a|b)Matchs a or b
 \wany Alphanumeric character
 \Wany Non-alphanumeric character
 \dany Digit
 \Dany Non-digit character
 \sany Whitespace
 \Sany Non-whitespace character





Lesson 1: An Introduction and the ABCs

Regular expressions are extremely useful in extracting information from text such as code, log files, spreadsheets, or even documents. And while there is a lot of theory behind formal languages, these sets of lessons and examples will explore the more practical uses of regular expressions so that you can use them as quickly as possible.

The first thing to recognize when using regular expressions is that everything is essentially a character, and we are writing patterns to match a specific sequence of characters (also known as a string). Ascii, or latin, letters include those on your keyboard as a subset, and unicode characters can be used to match foreign text. They include digits and punctuation and all the special characters like %#$@!.

Below are a couple similar strings, notice how the text changes to highlight matches as you type. A pattern that matches all the strings below may be as simple as the exact letters that are common in each string. If you enter a pattern that does not match all three strings, you will be notified in the results column.

task text result
match text abcdefg
match text abcde
match text abc
 
Try and solve the task above to continue on to the next lesson or problem.