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 metacharacters 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 preceeding slash distinguishes it from the simple d character and indicates that it is a metacharacter.

Below are a few more lines of text 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.

Exercise 1½: Matching digits
Task Text  
match abc123xyz To be completed
match define "123" To be completed
match var g = 123; To be completed
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 problem, or read the Solution.