Lesson 1½: The 123s

Characters include normal letters, but digits as well. In fact, numbers 0-9 are also just characters and if you look at an ascii table, they are listed sequentially.

Over the various lessons, you will be introduced to a number of special characters used in regular expressions that can be used to match a specific type of character. In this case, the character \d can be used in place of any digit from 0 to 9. The slash that comes first distinguishes it from the simple d character.

Below are a few more similar strings containing digits. Try and write a pattern that matches all the digits in the strings below, and notice how your pattern matches anywhere within the string, not just starting at the first character. We will learn how to control this in a later lesson.

your task text result
match text abc123xyz ?
match text define “123” ?
match text var g = 123; ?
Solution Try typing the common numbers '123' from all the lines to see them match.
Solve the above task to continue on to the next lesson, or read the Solution.